Forum Moderators: open

Message Too Old, No Replies

Help! save me from the loopy Netscape please!

NN4's built in reload conflicts with my onResize script.

         

Michael_O

6:04 am on May 4, 2002 (gmt 0)



I've cobbled together the code below which works perfectly on IE 5 on Macs & PCs (I'm on a Mac under OS 9.1) and partially works on NN6/Mozilla - the availHeight argument is O.K. but the availWidth one allows the screen to over-span by ca. 5%. The same code puts NN4.76/4.79 into a loop of constant resizing/reloading necessitating a forced quit which sometimes crashes the system - not something I'd like to do to someone else's computer.
<head>
<TITLE> onResize Netscape 4 loops!</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue = true;
}
//-->
</script>
</head>
<body onResize="window.location.href = window.location.href;" topmargin="0" leftmargin="1" marginwidth="0" marginheight="0">etc. ...
I'm completely stuck with this so any help would be very welcome.
TIA
Michael O'Brien

Michael_O

2:45 pm on May 4, 2002 (gmt 0)



Thanks very much for that rc.

Your tip solves NN4 onResize bug for pages without my onResize script but not those with it.

There are two issues causing my NN4 loop, as far as I can tell. The
(screen.availWidth,screen.availHeight) argument is not recognised by the browser - inclusing NN6 which overspans ca. 5%, and secondly body onResize="window.location.href = window.location.href;" conflicts with NN4's onResize bug.

As usual I want my cake and eat it!

Thanks again for the try though,

Michael O

MikeFoster

6:17 pm on May 6, 2002 (gmt 0)

10+ Year Member



If you really must resize the user's browser, do it before installing the resize listener. Try the following. I tested it with IE5.01, Opera6.01, NN4.79, and Mozilla0.9.7 on Win2K.

<html>
<head>
<script type='text/javascript'>
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);
var originalW, originalH;
window.onload = function() {
if (window.opera ¦¦ document.layers) {
originalW = window.innerWidth;
originalH = window.innerHeight;
setTimeout("simResizeEvent()", 500);
}
else if (window.addEventListener) {
window.addEventListener('resize', resizeListener, false);
}
else {
window.onresize = resizeListener;
}
}
function resizeListener() {
if (window.opera) location.href = location.href;
else history.go(0);
}
function simResizeEvent() {
if (window.innerWidth != originalW ¦¦ window.innerHeight != originalH) {
resizeListener();
}
else setTimeout("simResizeEvent()", 500);
}
</script>
</head>
<body marginwidth='0' marginheight='0'>
<h1>window onresize event example</h1>
</body>
</html>

Michael_O

6:48 am on May 10, 2002 (gmt 0)



Thank you very much Mike for the very clean piece of code which I just got after a few days away at the sea.

Great idea to clear the loop by adding the addEventListener. NN4.79 on a Mac now opens the page as if it were NN6 - ie. over-spanned by ca. 5% but that's progress compared with its machine-crashing previous infinite-loop. Unlike NN6 it no longer resizes the page when the user resizes to adjust this overspan.

I'll go away and play with this to see what I can combine.

Thanks again for the feedback

Michael O