PDA

View Full Version : window.onresize


Cornelius7
04-26-2001, 10:36 AM
Hi,
I have the following problem with the onresize event in Netscape:
I have lot's of absolute positioned divs on my page which are all incorrectly placed after resizing the browser. I have tried the onresize event and when document.layers is true I call document.location.reload
It works to some extend, however, I have an image which is 1024px in width and resizeing the browser to smaller than 1024 will cause the browser to endlessly reload ... In addition, it seems that Netscape calls the onresize event when first loading the page. Why would it do that and is there a workaround?

Thanks.

Syst3m Err0r
05-26-2001, 02:04 PM
This might reveal some awnsers...

have tried the onresize event and when document.layers is true I call document.location.reload

You say if page contains layer then reload... if true it reloads and reads the script again and reloads and...

I have lot's of absolute positioned divs on my page which are all incorrectly placed after resizing the browser.

Netscape records those into percentages (normally it's about the frames widths/heights but I'm almost sure this is also the cause for positioning layers)

EXAMPLE HOW NETSCAPES WORKS

When you have a 800 x 600 browsr window, its innerWidth is 796 pixels wide.

You have a layer/frame positioned at 250 from the leftside.

(250 / 796) * 100 = 31.40703517588

Which NS rounds down to 31 (NS uses integers)
To create the frame/layer NS measures its size as

(31 * 796) / 100 = 246.76

which rounds down to 246 pixels. See the precision is lost twice...

The easiest solution is to create a broswer window with Javascript that cannot be scaled. (especially windows with an innerheigt/width that gives exact percentages like for example 600 x 400)