Forum Moderators: open
I need to open a new window (using window.open) onUnload and Netscape 7.0 and Mozilla are not displaying them (I think they are just ignoring the call). Is there any way to enable that? Any setting, preference, or any way around it?
I need to perform some unlocking tasks (basically cleanup) when the user clicks the exit button.
I have tried a lot of ways and they all fail. One of the ways that I tried (failed) is below (it works in IE) - just to illustrate:
<html>
<head>
<title>Main Window</title>
<script>
function TheWindowIsBeingClosed()
{ window.open("http://cnn.com");
}
</script>
</head>
<body onunload=TheWindowIsBeingClosed()>
</body>
</html>
Any help appreciated! (This is really important to me.)
Thanks
Stanley
There is a cool Prefbar applet [xulplanet.com] that gives you quick access to these preferences and more.
AFAIK, there is no scripting way around this. This is, IMHO, a good thing.
Another issue to consider is this: What happens if I visit your site with Opera or Mozilla, and
I have specifically disallowed unsolicited pop-ups? What happens if I intentionally disable
JavaScript? Make sure that those objects which need to be unlocked on exit are handled properly
in these cases, even if it means detecting my popup disallow or disabled JS and giving me an error
message before locking them. You probably don't want to lock those objects in the first place if
they can't be unlocked later! As described, you are relying on the user to have JS enabled and
popups allowed - maybe not a good idea, since Mozilla and Opera are touting their ability to reject
popups, and consumers like that option...
Jim
I tried that, and it still does not work. Try the script & you'll see it does not open a new window when you close the browse (IE will open it).
Also, how do you install the applet?
Regarding Jim's post, you are right, but this is for our internal application, and those preferences are required.
Thanks anyway,
Stanley
I tried that, and it still does not work. Try the script & you'll see it does not open a new window when you close the browse (IE will open it).
Wierdly, it works for me if I don't close the entire browser but just a tab. Try opening two tabs, and you'll see what I mean. This could be a bug, maybe.
Also, how do you install the applet?
Click on the "Install now" hyperlink (top left, above the screenshot).
[edited by: moonbiter at 3:01 pm (utc) on Aug. 7, 2002]
Bug url:
window.open works in onunload in tabbed window but not in normal window [bugzilla.mozilla.org]
I assume that's the direction that Moz is now taking.
<edited for spelling>
[edited by: tedster at 8:33 pm (utc) on Aug. 7, 2002]
IMHO, the Mozilla team is doing an incomplete job if they disable window.open() on window.onunload events for closing a window, but not for closing a tab! After all, the stated reason they have left it out is because of abuse by malicious webmasters using "hydra ads" -- but if you browse with many tabs (like I do), then you have a similar problem. <added>I've asked them this on the bug report stankb submitted. Let's see what they say.</added>