JavaScript EditorBest javascript editor debugger     Ajax website 

Main Page

Previous Page
Next Page

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:

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

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

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

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

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

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.

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

Type )" to finish the JavaScript code.

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.


  • 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.

Previous Page
Next Page

JavaScript EditorBest javascript editor debugger     Ajax website