View Full Version : open a new window when user click the browser close button
css2code
04-04-2006, 08:56 PM
is there a code that will display a new window when the browser [x] button was closed?
thanks in advanced!
nikkiH
04-04-2006, 09:03 PM
Yes, but it's not overly reliable, tends to work only in MSIE, and tends to aggravate the hell out of people. ;)
This being a public forum, I won't post the code here where just anyone can see it and Google it, but if it's for a legit purpose (not spamming or 16 gajillion pop-unders) I'll share privately.
I reiterate that it tends to be MSIE only and is NOT 100% reliable, in case that matters to you. If it's to prompt users to save data or some such important thing, do not rely on this method.
css2code
04-04-2006, 09:26 PM
Hi,
thanks for replying.
yes i really needed this. the script should display the new window before closing the the current window.
can you send it to me privately?
thanks in advance.
nikkiH
04-04-2006, 09:36 PM
PM'd vbscript version.
nikkiH
04-04-2006, 09:37 PM
Oh, and it opens the window after the first closes. I think you might be able to cancel the close, but I've never tried it.
felgall
04-04-2006, 10:28 PM
The built-in popup blocker in IE would surely block that code wouldn't it? The whole point of popup blockers is that only windows you specifically ask to open should open and one attached to the close button is not being requested by your visitor and so should be blocked.
nikkiH
04-04-2006, 10:32 PM
Among other things that make it fail, absolutely.
Like I said, not very reliable.
Really shouldn't be used except in very limited intranet, HTA, or other trusted apps. And even then, sparingly. A well-coded application wouldn't need this to begin with, but sometimes we're stuck with other people's crappy back-ends... :p
css2code
04-04-2006, 11:32 PM
the purpose of this is for confirmation if user want to save the data that has not been saved.
the new pop up window would say " there are unsaved data to you want to continue" [yes] [no]
the code you gave opens the window even if i dont click the browser x button
thanks!
Bill Posters
04-05-2006, 09:34 AM
This being a public forum, I won't post the code here where just anyone can see it and Google it, but if it's for a legit purpose (not spamming or 16 gajillion pop-unders) I'll share privately.
Sorry, but that 'I know, but I won't tell you' attitude really gets my back up.
We should…
• Give others the knowledge of how to do what they want to do and ideally enough info for them to know when and when not to use it.
• Stop assuming that their purposes are malevolent.
• Stop 'protecting' their users from them. (Stop assuming we know their sites and their users better than they do.)
Yes, it can be argued that we each have a duty to encourage best practices on the web - and that's something I'm totally behind. But, I really do not see the key to achieving that as establishing an underclass of developers which we keep in the dark about the techniques which we frown upon.
If someone wants to know, tell them.
Don't sit in prejudgement over what a person should or shouldn't know, when you have the knowledge and interest to inform and educate them.
Ultimately, imho, if you're not willing to post without assurances that the technique won't be used in ways which you disagree with then you shouldn't even bother posting in the first place.
If you're not willing to post just the technique for fear that readers might go away and use it in annying ways, don't post. Just ignore the thread.
By all means, assist, advise and guide, but don't censor.
…please.
After all, we're only talking about web development techniques. It's not as if someone's asked for information on how to make a dirty bomb.
(None of this is to say that I like or endorse the use of 'exit popups', though there are instances where it would be acceptable.)
</rant> ;)
nikkiH
04-05-2006, 04:47 PM
"Sorry, but that 'I know, but I won't tell you' attitude really gets my back up."
I know, it does to a lot of people.
Sorry it bugs you. ;)
It bugs me when people post open questions and don't say why they want it, because sometimes, there is a much better solution to their issue, or sometimes, a simple Google search brings up a great match... :D
Here's a dotnet solution. Modify it as needed for your app.
http://www.4guysfromrolla.com/webtech/100604-1.shtml
Bill Posters
04-05-2006, 06:52 PM
It bugs me when people post open questions and don't say why they want it, because sometimes, there is a much better solution to their issue
Heal the world, eh? ;)
I appreciate that and, by all means, ask them what they want it for. But don't dangle the solution just out of reach until they satisfy your concerns. If nothing else, it patronising and makes assumptions about the OP which are best not made.
Give them the solution and tag a cautionary note onto the post letting the OP know that it may not be the best solution for whatever it is they're trying to ultimately achieve.
or sometimes, a simple Google search brings up a great match... :D
I suspect that there are few, if any, subjects and solutions covered here at CF which aren't also discussed and solved elsewhere, but if we just say 'Google it', isn't that missing the point of CF?
(That said, more posters could and should be directed to the topic-based FAQ threads here at CF.)
It's no biggie. I just don't think the 'tell me what you want it for and I might tell you' approach has any place on a forum where the idea is to share knowledge. If it has, at least let's try not to be so brazen about it. ;)
nikkiH
04-06-2006, 02:03 PM
Point taken. :D
felgall
04-07-2006, 12:50 AM
There are many instances of repeat questions where the same question is asked by hundreds of different people across various forums where the question that they ask is only indirectly related to what they are trying to achieve. After seeing many similar questions you get a feel for what 99% of the askers are trying to achieve and so I then try to answer the question based on what 99% of the askers are trying to achieve rather than what is actually being asked. This means that I am short circuiting the question and answer process in 99% of cases but may be giving a wrong answer in the remaining 1%.
In the case of automatic popups - in 99% of cases popup blockers will block ANY attempt to open a popup automatically. The only place where automatic popus can be relied on to open is on INTRAnets.
Since 9999 out of 10000 people asking questions on forums are asking about how to do things on the INTERnet those who are asking in connection with INTRAnets should make that clear in their question since most web page function type questions have a different answer for this 0.01% of those asking and the answer they are likely to get if they don't say that up front is the one that applies to the other 99.99% of the people who ask that question..
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.