SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    Shelby, NC USA
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem: this.close() causes 'window close?' dialog box to appear

    If I use onclick="this.close()" to close the browser (not just a window) the following dialog box pops up:

    "The Web page you are viewing is trying to close the window.
    Do you want to close this window."

    Is there a way to prevent this? Thanks for any and all help.
    Earl Parker II

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Because of the potential for abuse, no.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    Shelby, NC USA
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was afraid of that... thanks for letting me know!
    Earl Parker II

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, there's a little hack that makes this work. It's been discussed here before - I'll look for it...


    ... here it is

  5. #5
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but this article is making the parent window as the top window and then it closes it.

    I got into the same very problem, if my broweser window is opened as new from another window or as child and i do window.close, it doesn't prompt for confirmation but if i have window.close on the new window then it does.

    I am still trying to find the answer for this but am not successfull.

  6. #6
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This is something that is browser-specific. It's a good thing, not a bad thing. If somebody has set their preferences to prevent windows from closing without permission, then it's because they don't want windows to close without permission. For maximum usability you should not try to work around this.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  7. #7
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Generally, from security point of view, you can close only those windows with any prompt, which you have created through client side scripts.

    In IE6 on Win(that's where I've tested), this.close() or self.close() will close the browser window without any prompts but not in other browsers or previous versions of IE.
    There's an activeX control in IE/Win that closes the window without any prompt in all versions but then you are restricted to IE/Win with that.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  8. #8
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Phoenix, AZ
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I've done to close any window without getting the prompt (IE6):

    window.opener = window
    window.close()

  9. #9
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Also, you can close windows in IE6 through simple self.close() without raising the prompt. Though in other browsers & previous versions of IE, you'll get the prompt.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  10. #10
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by asp_funda
    Also, you can close windows in IE6 through simple self.close() without raising the prompt. Though in other browsers & previous versions of IE, you'll get the prompt.
    I've gotten the prompt in IE6 before. Can't remember why or how but I did (it was a LONG time ago). If I can recreate it I'll post here.

  11. #11
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeah, when I upgraded from v5.5 to v6, I used to get the prompt in the beginning. But after some time, it stopped coming. Don't know why. Maybe I fiddled with some configuration or something else.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  12. #12
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FatTonny
    This is what I've done to close any window without getting the prompt (IE6):

    window.opener = window
    window.close()
    Good This works, in IE 6.0 I just check it, Other like self.close(), this.close() prompt the message
    Irfan
    Find Tutors Easyway to get connect with your tutor in india


Bookmarks

Posting Permissions

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