Practical PC
Stripe

Reviews
Web Building Guides
Computing Guides
Opinion
Downloads
About Practical PC


 

 
Sections
Getting Started
For the absolute novice.
 
Web Building software
The tools of the trade.
 
Design Tips
How to make your Web site look great
 
Web Building scripts
Things that make your Web site dazzle.

 

Web Bulding Guides
 PPC> Web building> Scripts  

Browser Window Re-Sizer

Sometimes, you really need your surfers to see a page at a specific size. David Dorn has a dinky little JavaScript that will help

This script works in: Netscape 4 and above, IE5 and above

When you create your Web pages, they should, really, scale to any size, but sometimes you may have a specific layout or design that you'd rather stayed the way it is. This little script can help there. What it does is to set the size of the browser window to dimensions you decide, and then, when the reader leaves that page, re-sets their browser back to the size it was.

It's actually a very simple script, so simple that it's only three lines:

<SCRIPT> 
window.resizeTo(600,800); 
</SCRIPT>

You just need to <copy> those lines and <paste> then into the <HEAD> section of the page you're creating (straight after the <HEAD> tag is a good place) and your visitor will see the page at the size you want - once you've replaced the "600" and "800" with the depth and width you require.

The code you need to use to let their browser re-size when they leave the page is also very short:

<SCRIPT LANGUAGE="javascript">
var width = screen.width
var height = screen.height
document.write("<BODY onUnload=window.resizeTo("+width+ "," +height+")>")
</SCRIPT> 

This, too, nestles in the <HEAD> section of the page - click here to see the example and view the code actually in use (it opens a new window).

Note: this is cross-browser, but Internet Explorer handles the code strangely sometimes, especially if you use a very large desktop resolution (that is, 1600x1200). At lower, more normal resolutions, it works fine.

You could, of course, force re-size every browser window in your site!

Enjoy!


 

David Dorn


 
counter