Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: script help

  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script help

    I have wrote the following script to open a new window and close the parent window. It works great but I would like the parent window to stay open if the new window is blocked by a popup blocker.

    Is there an easy way to do this?

    The code I have now is as follows:


    </head>

    <html>
    <head>
    <script language=javascript>
    function CloseWindow()
    {
    window.open('index.html','','')
    window.open('','_self','');
    window.close();
    }
    </script>
    </head>

    <body onload="CloseWindow()">

    If your magazine does not load then click <a href="index.html">here</a> or enable pop-ups for this site.

    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this code

    Code:
    <script language=javascript>
    function CloseWindow()
    {
    hwindow = window.open('index.html','','');
    if (hwindow)
    window.close();
    }
    </script>
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Closing the parent window is not a good idea. Tabbed browsers are in nowadays, so all other pages opened by the user are gone if you close the window (but good thing browser asks confirmation to close the window if there are many tabs open). And the code you posted is a bug exploit. I don't know if any browser has fixed that bug but nevertheless, you should not rely on that exploit. It might work today, but not in the future.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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