Discuss how to use and promote Web standards with the Mozilla Gecko engine.
I have something in my page depended of the browser window size. To get the page correctly displayed after resizing the window, I wrote:
This work fine in MSIE, but Mozilla 1.7.6/Windows seemly do nothing on the window resizing. If I write
If this a Mozilla bug or something is wrong in my code? How to get program equivalent of the Refresh button and
reexecute a code like document.write() when user is resizing the window?
First of all, onresize and window.location.reload() are proprietary (nonstandard) features, meaning you should never expect them to work in all browsers.
That said, Mozilla does support the onresize property and document.location.reload();. Note that that's document.location, not window.location.
In fact, location.reload() is enough
it's body.onresize that's not supported.
window.onresize is supported
I'm not a fan of document.location, because the document object is standardized and location is not a standard property of it. The window object is not standardized at all, but browsers tend to agree on what it supports. When standards do apply, I'm not keen on adding things to them. When standards don't apply: fair game.
window.location.reload() is from the "DOM level 0". Yes, this DOM is nonstandard at all, but commonly used. This is supported by both old browser brands - Netscape and MS (document.location is a much more nonstandard, marked as obsolete starting from NN3). Any replace in DOM 2? I can't find yet.
jonnyq, please read the original message before answering . I think both window.onresize=... and <body onresize=...> are working,
but [window.]location.reload() don't.
DOM is standardized (Document Object Model). There is no "replacement" for document.location in any DOM standard. "location" really doesn't belong in the scope of the document - it belongs in the scope of the window.
The window object, its properties, and its methods are not standardized (labeled DOM Level 0, which is almost a misleading term). Hopefully someone will standardize the window object at some point, but that's yet to come. (my vote is that ECMAScript standardize it, not W3C DOM)
I would stick to the code I gave... heck... it's one line...
document.location is read-only. window.location is not.
Maybe a full sample page will help to undestand the problem:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
document.documentElement && document.documentElement.clientWidth ||
document.documentElement && document.documentElement.clientHeight ||
alert('Screen:'+window.innerWidth+' x '+window.innerHeight);
// This is NOT reexecuted on resize !!!
<body onresize="alert('onresize event'); window.location.reload();">
Try to resize the browser window.
alert('I want to use document.write() to change something here');
// ...but it is NOT reexecuted also !!!
Yes it does.
works for me.
But oddly, I guess my code doesn't work:
The alert appears, but no reload.
It appears that Firefox, for security/annoyance reasons, won't let you reload a window on a resize event. I don't see a preference to change this behavior.
I don't undestand this page. Why the resolution is invalid? How to get the full description?
Some pages did what you're trying to do. onresize fires when the find and pop-up toolbar appear. Therefore, these sites would reload whenever the user used find-as-you-type and they would reload infinitely if they included a pop-up. That's bad, so the devs disabled reloading on resize.
Why are you trying to do this, anyway?
Someone mentioned that find bar should float on top of the page. I don't like that idea because it might cover up content and make the scrollbar a bit confusing.
Wouldn't there be an easier solution where they could keep the find bar from firing a resize event?
There are many other bad things like reloading on tiimer (try such page on slow link ). The Firefox team solution sounds like disabling
the 'for' statement because bad progammers use it to make infinite loops . Is a workaround exist?
The point was that a very popular site (Washington Post) didn't work in Firefox because of it. Infinite loops are also given a way out in most cases (a prompt comes up to ask you whether to keep running) and if you gave them a solution to the halting problem, I'm sure they'd disable infinite loops altogether.
The workaround is to not do it.
But the page is resizing and that would break all the sane onresize implementations.
Who is online
Users browsing this forum: No registered users and 2 guests