Lesson 4- Windows
When we talk about windows in this lesson we are speaking of the browser
screens not the operating system. If you press control-N, you open a new
window. The window methods allow the site creator to open and close a user's
windows.
Window Methods
<script type="text/javascript">
mywindow = window.open()
mywindow.document.write("hi")
mywindow.document.close()
</script>
Line by Line
- mywindow = window.open()
- mywindow is just a name to use as a reference to the
window just like when we used the variable textstring with the message box in
lesson 2.
- window.open() is the method to open a new window. The
arguments of this method include URLs, the windows name, and a bunch of options
for the windows (we'll go over this more later).
- Remember to keep the arguments in order. You can only do:
"mywindow=window.open(url, title, options)" and this is written as:
"mywindow=window.open("http://google.com","blah","width=200,
height=200")". If you don't have one of the arguments - say you don't care
about the name, it would look like:
"mywindow=window.open("http://google.com","","width=200,
height=200")"
- mywindow.document.write("hi")
- window.write is a method that allows you to write in the
window. It takes an argument which is whatever you want to write in there. We
will say "hi".
- mywindow.document.close()
- This ends the description
There are a wide variety of options you can choose from
Congratulations, you have finished Lesson 4;
next lesson |
home page