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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how close popups?

    i dont know how to close popups by itself. i did window.open () and refresh but how can i make it close automaticly with time remaining?
    thank you.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    If I understand you correctly, you want to close a pop-up window automatically after a certain period of time.

    Try this:-

    Place the following in the <body> tag:-

    onLoad= "setTimeout('window.close()',5000)"; // 5000 is time in milliseconds, i.e. 5 seconds or whatever value is appropriate.
    Last edited by Philip M; 07-08-2007 at 08:10 PM.

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile thanks

    appriciate for ur help but i think some thing is not right for what i have here. would u take a look and see where the problem cause? thank you

    <html>
    <head>
    <title>pop</title>
    </head>
    <body>


    <SCRIPT LANGUAGE="javascript">
    <!--
    window.open ()
    -->
    </SCRIPT>
    <meta http-equiv="refresh" content=".2">
    </body>
    onLoad= "setTimeout()',1)"; //
    </html>

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Place the following in the <body> tag:-

    onLoad= "setTimeout ('window.close()', 5000)"; // 5000 is time in milliseconds, i.e. 5 seconds or whatever value is appropriate.

    Thus:-

    <html>
    <head>
    <title>pop</title>

    <script type = "text/javascript">
    window.open ();
    </script>

    </head>

    <body onLoad = "setTimeout('window.close()', 5000)";>

    <The text or content of your pop-up window goes in here>

    </body>
    </html>

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Unless, I'm mistaken, I think the idea is that the main window contains the popup script and the popup contains the self-closing script.

    e.g.

    parent document...
    Code:
    ...
    
    <script type="text/javascript">
    
    	window.open('urlofchilddocument');
    
    </script>
    </head>
    ...
    child document (in popup window)
    Code:
    ...
    
    <script type="text/javascript">
    
    	window.onload = function() {
    
    		setTimeout('window.close()', 5000);
    
    	}
    
    </script>
    </head>
    ...
    ...sorta thing.


  •  

    Posting Permissions

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