Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Location
    Leicester UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Suppress IE window closing message

    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!)

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mjscom2001
    (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.
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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()">
    Last edited by Mr J; 06-05-2004 at 07:44 PM.

  • #4
    New to the CF scene
    Join Date
    Jun 2004
    Location
    Leicester UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bradyj:
    Quote Originally Posted by 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 !!!
    However, I tried your code and it worked fine!


    Thanks for your replies guys

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by Mr J
    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.
    closing a window from another page

  • #6
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mjscom2001
    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 -- 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
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by Willy Duitt
    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.
    Quote Originally Posted by Mr J
    I don't think you should be getting that from a popup
    I think that mjscom2001 just confused popup with the main window.

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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()

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •