You are here: irt.org | FAQ | JavaScript | Window | Q1626 [ previous next ]
The following stops the window being resized in the horizontal direction:
<html> <head> <title>fix horizontal</title> lt;script language="JavaScript"><!-- var fixedWidth; function getH() { if (document.body && document.body.clientWidth) fixedWidth = document.body.clientWidth; else if (window.outerWidth) fixedWidth = window.outerWidth; } function resize() { if (document.body && document.body.clientWidth) document.body.clientWidth = fixedWidth; else if (window.outerWidth) window.outerWidth = fixedWidth; } //--></script> </head> <body onLoad="getH()" onResize="resize()"> ... </body> </html>
The following stops the window being resized in the vertical direction:
<html> <head> <title>fix vertical</title> <script language="JavaScript"><!-- var fixedHeight; function getH() { if (document.body && document.body.clientHeight) fixedHeight = document.body.clientHeight; else if (window.outerHeight) fixedHeight = window.outerHeight; } function resize() { if (document.body && document.body.clientHeight) document.body.clientHeight = fixedHeight; else if (window.outerHeight) window.outerHeight = fixedHeight; } //--></script> </head> <body onLoad="getW()" onResize="resize()"> ... </body> </html>