SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    alert close window

    how can i use this alert so when i click ok it closes the browser window:

    <script language="Javascript">

    <!--

    alert ("You have been kicked!")
    //-->

    </script>
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You can only close a browser window from JavaScript that you opened from JavaScript. Any window that your visitor already had open when they accessed your page cannot be closed by you.

    To close the current window when you opened it you would call self.close() from within the window itself or if calling from the window that opened it you would use the variable you assigned the window.open() to in place of self.
    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
  •