Working With Windows 1
In this section, we'll learn how to make a pop-up window.
The first piece of information (parameter) is the URL of the web page we'd like to open in the new window. The second piece of information is the name we'd like the window to be known as to our scripts. The third piece of information is the window attributes, i.e. what size we want it to be, if we want a location bar to be on it, etc.
In its one of its most simple forms, it looks like this:
If you were to put this in a web page as is, as soon as it hit this line of code, a new browser window would open with scrollbars, 525 pixels wide and 400 pixels high, loading http://www.davesite.com/.
In reality, this is kind of silly. In most cases, we won't want to open a new window without the person visiting our site telling us to do so.
The simplest way to get a window to open by permission is to use a link. A link would look something like this:
<a href="#" onClick="window.open('http://www.davesite.com/', 'WindowA', 'width=525,height=400,scrollbars=yes');">
Which looks like this (click to test):
A function allows us to do a whole lot of things at once. Functions must be enclosed within script tags, and we must give them a name. Here's a function that'll open our window whenever we use the words OpenOurWindow() in an event.