HTML and CSS Reference
In-Depth Information
At the end of the function, I return false . That's necessary so that the event handler used
to call the function is stopped. To illustrate what I mean, it's necessary to explain how
this function is called. Instead of using the target attribute in the <a> tag, the onclick
handler is used, as follows:
<a href=“whatever.html” target=”_blank” onclick=“popup('whatever.html')”>Pop
up</a>
Ordinarily, when a user clicks the link, the browser calls the function and then goes right
back to whatever it was doing before, navigating to the document specified in the href
attribute. Returning false in the popup() function tells the browser not to continue what
it was doing, so the new window is opened by the function, and the browser doesn't fol-
low the link. If a user who had JavaScript turned off visited the page, the link to what-
ever.html would still open in a new window because I included the target attribute, too.
In the preceding example, I specified the height and width settings for the new window.
There are several more options available as well, which are listed in Table 17.4.
TABLE 17.4
Settings for Pop-Up Windows
Setting
Purpose
Height of the window in pixels.
height
Width of the window in pixels.
width
Enable window resizing.
resizable
Display scrollbars.
scrollbars
Display the browser status bar.
status
Display the browser toolbar.
toolbar
Display the browser's location bar.
location
Display the browser's menu bar (Not applicable on Mac OS X.).
menubar
Left coordinate of the new window onscreen (in pixels). By
default, pop-up windows are placed slightly to the right of the
spawning window.
left
Top coordinate of the new window onscreen (in pixels). By
default, pop-up windows are placed slightly below the top of the
spawning window.
top
When you specify the settings for a window, you must include them in a comma-
separated list, with no spaces anywhere. For the settings that allow you to enable or
disable a browser interface component, the valid values are on or off . Here's a valid list
of settings:
status=off,toolbar=off,location=off,left=200,top=100,width=300,height=300
 
 
Search WWH ::




Custom Search