SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: JS close window

  1. #1
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS close window

    I urgently need a piece of JS that will close the window when a user clicks a button.
    Using window.close works but it gives an alert box to ask the user if they want to close the window. Is there a way around this?

    Thanks in advance!

    GP


  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sorry, this is one of the most common javascript questions. The common answer? No.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually there seem to be a way of doing this. I haven't tried it but you can read about it here.

  4. #4
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    document.images is an IE check, thus the solution (if it really works, it seems a bit of a weirdy) would only work in browsers that have this DOM in place.

    But, hey, if I'm wrong I stand corrected
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  5. #5
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, I have looked into it a bit more and it does seem impossible as the thing is being designed without any knowledge of the targets environment.


  6. #6
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: JS close window

    Originally posted by glenplake
    I urgently need a piece of JS that will close the window when a user clicks a button.
    Using window.close works but it gives an alert box to ask the user if they want to close the window. Is there a way around this?

    Thanks in advance!

    GP

    Javascript ask that when you try to close a window which hasn't opened via javascript, ie, by window.open command (security reasons)
    Is that your case?

  7. #7
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    es, thats exactly it! We have worked around the problem now though? Thanks


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
  •