SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there anyother way of closing a window?

    A friend of mine is developing a web site, and at the moment he is using the usual window.close() me-larky to close a pop up window... But in Internet Explorer it comes up with a warning about 'this is trying to close the window' or something like that... Is there anyway around this, so this IE error message doesn't appear?

    Many thanks for any input.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of window.close(); use

    Code:
    var self = this;
    self.close();


  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The warning only comes up if you try to close a window you didn't open. Other browsers wont produce the warning and will just ignore the code instead.

    JavaScript can only close a window that was opened using a JavaScript window.open() call.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •