Results 1 to 9 of 9

Thread: auto close

  1. #1
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default auto close

    Hi Guys,
    Is it possible to code an Html page to auto close after 5 seconds after it loads up?

    Regards,
    Gav

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    I cannot see any viable use for this except as a popup script, but
    Code:
    <body onload="javascript:setTimeout(window.self.close(), 5*1000);">
    where 5 is the number of seconds you wish to close the page

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Many browsers will not allow that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That was great - Thanks a lot - except for that popup asking for confirmation to close - can that be avoided by any chance so the window closes on its own without notice

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by jscheuer1 View Post
    Many browsers will not allow that.
    err... what he said...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can spoof some browsers into thinking that the window was opened by javascript, but not all. Those that can be fooled will stop popping the confirmation question (note - some won't ask to begin with, just won't close the window). You could (if your set up lends itself to this strategy) actually open the window with javascript to begin with. Then, virtually any browser that will allow it to open in the first place, will allow it to close. However, many browsers will block it as a pop up, or if they have javascript disabled, not open it to begin with. In some tabbed browsers, a situation could arise where the entire browser closes, or attempts to close.

    Generally it's not nice to mess with windows, stick to the documents.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    HTML Code:
    <script type="text/javascript">
    function fullClose() {
    window.opener=self;
    window.close();
    }
    window.onload=function() {
    setTimeout(fullClose,5000);
    }
    </script>
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by tech_support View Post
    HTML Code:
    <script type="text/javascript">
    function fullClose() {
    window.opener=self;
    window.close();
    }
    window.onload=function() {
    setTimeout(fullClose,5000);
    }
    </script>
    Not in FF. Perhaps not in some others. Other of the issues I mentioned would still apply, even if the above worked in all browsers, which it doesn't.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Marvelous
    You guys got the brains - I really appreciate your help- that's exactly what I was looking for - Thank you John and Tech Support - I love you guys for the time every one in this forum puts in to help us

    - Not to forget Blizz thanks for being there all the time mate, you are my guardian angel I should say

    *********** Tech Support, Please check why my photo is not showing up besides my name - I had uploaded it yesterday **********
    Last edited by gavinv3; 10-28-2007 at 02:25 PM.

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
  •