...

View Full Version : Suppress IE window closing message



mjscom2001
06-05-2004, 02:55 PM
Hi all - I'm Mick, a newly registered member here.

I have a popup window with a close button at the bottom. The code is

<input type="button" value="Close This Window" name="close" onClick="window.close()">

When clicked IE displays the message "The web page you are viewing is trying to close the window. Do you want to close this window".

Is there any way to prevent this message appearing so that the window closes straight away? After all, if I didn't want to close the window I wouldn't have clicked the button!

Thanks in advance

Mick

(Before I get flamed, this particular popup is for a user to get additional info about a topic - it is NOT one of those damned annoying spam popups!)

bradyj
06-05-2004, 07:06 PM
(Before I get flamed, this particular popup is for a user to get additional info about a topic - it is NOT one of those damned annoying spam popups!)

They are still annoying:) However, to answer your question, I do not believe you can, or should do this. This is a setting that's built into the browser, a user would have to disable the setting personally on their browser, you can't override this. Nor should you, they may have it set up for a reason because they may accidentally click close. Safeguards.

Mr J
06-05-2004, 07:38 PM
I don't think you should be getting that from a popup that message usually happens if you are trying to close the parent window that has no history, er ....maybe

You could try the following

<script>
<!--

function close_me(){
window.opener = top;
window.close()
}

// -->
</script>




<input type="button" value="Close This Window" name="close" onClick="close_me()">

mjscom2001
06-05-2004, 09:18 PM
bradyj:

They are still annoying.

How can it be annoying if the user has clicked a link requesting this extra info :)

Seriously though, I agree - if it is a browser setting then it should not be overwritten. But having looked through my IE (v6) options I can't see where it is set.


Mr J:
I am not sure I understand your first sentence :confused: !!!
However, I tried your code and it worked fine!


Thanks for your replies guys :thumbsup:

glenngv
06-07-2004, 06:12 AM
I don't think you should be getting that from a popup that message usually happens if you are trying to close the parent window that has no history, er ....maybe

You could try the following

<script>
<!--

function close_me(){
window.opener = top;
window.close()
}

// -->
</script>




<input type="button" value="Close This Window" name="close" onClick="close_me()">
That is a bug exploit, so you can't rely on it to work in future browser releases.
http://www.codingforums.com/showthread.php?t=37466

bradyj
06-07-2004, 06:35 AM
bradyj:


How can it be annoying if the user has clicked a link requesting this extra info :)

Did they click on it requesting extra info... in a new pop up window? Hey, as long as you warn me :D -- I understand your reasoning, I just still hate it. Much less, I'll never have to worry about it, I have it blocked.

Thanks Mr J and glennv for answering while I was debating:)

Willy Duitt
06-07-2004, 10:37 AM
If the user clicked on a link to open a popup window, I do not understand why the Security Alert is fired when the popup is closed. Something is wrong but it would be hard to say what since we haven't seen any code.

glenngv
06-07-2004, 10:59 AM
I do not understand why the Security Alert is fired when the popup is closed
not the popup (as Mr J pointed out) but the parent window that opens the popup.

I don't think you should be getting that from a popup

I think that mjscom2001 just confused popup with the main window.

Willy Duitt
06-07-2004, 11:21 AM
Hmmm;

Now I'm really confused. Is the O/P wanting to close the popup or the parent?


I have a popup window with a close button at the bottom. The code is

<input type="button" value="Close This Window" name="close" onClick="window.close()">


I read the above as closing the popup from a button within the popup and in such case, I would suggest changing window.close() to self.close()

glenngv
06-07-2004, 11:38 AM
Don't rely too much on his words (as I think he is confused) but on the end result.


When clicked IE displays the message "The web page you are viewing is trying to close the window. Do you want to close this window".

You only get that when you are trying to close the main window.
And when Mr J suggested a solution that closes the main window without prompt, he said it works.


Mr J:
I am not sure I understand your first sentence !!!
However, I tried your code and it worked fine!


Although I must admit that I'm also confused with his contradicting statements. I just relied on the end result that he mentioned.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum