Setting a New Window s Size


Setting a New Window's Size

In Chapter 6, you learned how to open a link in a new window. JavaScript lets you control how big that window should be.

To set the size of a new window:

1.

Type <a href="javascript:location='current.html';, where current.html is the URL of the page that contains the link.

2.

Type window.open('nextpage.html', where nextpage.html is the URL of the page to be opened in the new window.

3.

Type 'label', where label is the name of the new window.

4.

Type 'height=h,width=w, where h and w are the desired height and width for the new window. (No spaces!)

5.

If desired, type ,chrome=yes, where chrome is scrollbars, toolbar, status, menubar, location, or resizable.

6.

If desired, type a, (comma) and repeat step 5 as desired. Each window part should be separated from the previous one with a comma but no spaces.

7.

Type ' (a straight apostrophe)whether or not you've set the window parts.

8.

Type )" to finish the JavaScript code.

9.

Type >clickable text</a>.

Figure 20.4. The file name of the document shown here is hawthorne.html. The first part of the JavaScript statement says "keep displaying the hawthorne.html document right where it is". The second part of the JavaScript code says "and then open a window labeled characters that's 150 pixels by 150 pixels, with scrollbars, and display the hester.html file in it".


Figure 20.5. When the visitor clicks a link...


Figure 20.6. ...the link is displayed in the new window. Contrast this example with the one shown in Figure 6.13 on page 108.


Tip

  • To open a new window automatically as the main page loads (with no link at all), type onload="javascript: and then follow steps 28 above within the body tag of your main page's (X)HTML code. Then open other links in the new window by using target="label", where label matches step 3. For details, see page 108.





HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net