SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    closing the browser window/tab in mozilla/safari

    Hi,

    How could close the browser window in mozilla or safari.

    window.close is working in IE/Opera but not in mozilla/safari?

    Can any one help me out?

    Thank you,

    b

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Hi babuacp, welome to the forums.
    window.close() works for me in Firefox.
    HTML Code:
    <html><head><title>close window test</title>
    <script type="text/javascript">
    function say_bye(){
    window.close();
    }
    </script>
    </head>
    <body>
    <div onclick="say_bye();">click here to close window</div>
    </body></html>
    What does your code look like?

  3. #3
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.I tried the above code but it is not working for me.

    and also below too.

    <a onclick="window.close();">click here to close window</a>

    Thank you,

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    What version of Firefox are you using?
    Are you certain javascript is enabled?
    Any plugins or extensions that could be involved?
    Does the following give an alert?
    HTML Code:
    <html><head><title>close window test</title>
    <script type="text/javascript">
    function say_bye(){
    alert("closing");
    window.close();
    }
    </script>
    </head>
    <body>
    <div onclick="say_bye();">click here to close window</div>
    </body></html>

  5. #5
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using firefox 3.0.1, and its not working in 2... .Yes , its giving alert message.and javascript is enabled.

    Thank you

  6. #6
    SitePoint Enthusiast mexabet's Avatar
    Join Date
    Jul 2008
    Location
    mexabet.biz
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using Firefox, IE, Flock, Safari, Netscape Navigator and Opera and this code works fine in all of them:
    Code:
    <a href="javascript: window.close()">Close</a>
    Quote Originally Posted by babuacp View Post
    I am using firefox 3.0.1, and its not working in 2... .Yes , its giving alert message.and javascript is enabled.

    Thank you
    The Best Is Yet To Come!

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mexabet and Mittineague,

    Are you using for popups?

    I have seen some ifo here:
    http://www.webdeveloper.com/forum/sh...d.php?t=153088


    http://bytes.com/forum/thread534885.html

    thank you,

  8. #8
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not for the popups.i am not sure hwy is n't working?

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Did you open the window with JavaScript in the first place?

    JavaScript is not allowed to close windows it didn't open.
    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="^$">

  10. #10
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    I could have sworn I tested the above in Firefox and it closed. But now (after upgrading to 2.0.16) it doesn't and I get the error console message
    Scripts may not close windows that were not opened by script.
    so I don't know what I did before (tested in Opera thinking I was using Firefox?? tesing a different window.open()/window.close() script??).
    Sorry for the confusion, but if you google the error message you'll see this has been around for a while.

  11. #11
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay.. thank you..is there any other way we could close the window(which is not opened by javascript)?

    no way??

    thank you,

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    if you didn't open the window then the only way to close it is to be logged on to that computer either by sitting in front of it or by getting the person whose computer it is to enable remote support.
    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="^$">

  13. #13
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
  •