Click to See Complete Forum and Search --> : Resize in IE


florida
12-16-2003, 06:50 AM
I have a resize function that works on body load in my Netscape 4.77 with no problems. But I cant get it to work in my IE 5.5 Browser. Please advise.



NS4 = document.layers;

if (NS4)
{
ourWidth = innerWidth;
ourHeight = innerHeight;
}

function the_Resize()
{
if (ourWidth != innerWidth || innerHeight != ourHeight)
{
location.reload();
}
}

if (NS4) onresize = the_Resize;


//in body onload
<body onLoad="the_Resize()">



My attempt trying to get it to work in IE:



NS4 = document.layers;
IE = document.all;

if ((NS4) || (IE))
{
ourWidth = innerWidth;
ourHeight = innerHeight;
}

function the_Resize()
{
if (ourWidth != innerWidth || innerHeight != ourHeight)
{
location.reload();
}
}

if ((NS4) || (IE))
onresize = the_Resize;



//in body onload
<body onLoad="the_Resize()">


It didnt work in IE. Please advise how I can get this to work?

gil davis
12-16-2003, 08:32 AM
You really don't need that code to work for any other browsers. It is used specifically for Netscape 4, because it does not have the capability to reflow a page created by JavaScript. All other browsers do the reflow without any help.

florida
12-16-2003, 09:04 AM
Thanks.

One addtional question about this resize script:

if (NS4) onresize = the_Resize;

Why isnt this call to this function written like this:

if (NS4) onresize = the_Resize();

with a parathesis after the function name???
I tried putting paranthesis and it didnt work and I thought this would definetelty need it in this case? How is it working without paranthesis?

gil davis
12-16-2003, 12:00 PM
The first example assigns the function to an event handler, so that each time the event occurs the assigned function is called.

The second example assigns whatever the function returns to the event handler, which in this case is null.