SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Please Help

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please Help

    I have a page that opens in a pop window. I want it to show the page then after x amount of seconds it will close the window. Does anyone have the code that will do that ?

    Thanks in advance

  2. #2
    Bimbo With A Brain! silver trophy Saz's Avatar
    Join Date
    Mar 2001
    Location
    Kent, United Kingdom
    Posts
    5,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This script opens a window with a button and then uses a timer to close it..........

    Put this bit into the head of your page....
    Code:
    <script>
    function winopen(){
            win = window.open("YOUR PAGE NAME", "newWin", "toolbar=yes,location=yes,directories=no,status=no, menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,width=400,height=260")
            startTime()
    }
    
    function startTime(){
    
            var time= new Date();
            hours= time.getHours();
            mins= time.getMinutes();
            secs= time.getSeconds();
            closeTime=hours*3600+mins*60+secs;
            closeTime+=3; // Amount of time that the window stays open in seconds
            Timer();
    
    }
    
    function Timer(){
            var time= new Date();
            hours= time.getHours();
            mins= time.getMinutes();
            secs= time.getSeconds();
            curTime=hours*3600+mins*60+secs
            if (curTime>=closeTime){
                    if (win.closed == false){
                            win.close()}}
            else{
                    window.setTimeout("Timer()",1000)}
    }
    </script>
    and this bit into the body........
    Code:
    <form><input type=button value="YOUR BUTTON DESCRIPTION" onClick="winopen();"></form>
    Saz: Naturally Blonde, Naturally Dizzy!
    No longer Editor of the Community Crier.

    Don't mind me, I'm having a BLONDE moment!

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Let me make more clear

    I am using ColdFusion. I have a form that is already open in a child window. When I submit the form to its action page the code on that action page will execute and then display the html stuff. What I want it to do is after it displays the html stuff I want it to automatically close this window. Something like the following -
    <META HTTP-EQUIV="refresh" content="3;URL=page.htm">

    But what I want is after 3 seconds the child window will close.

    Any suggestions. I have seen this somewhere but I can't find where I wrote it down.


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
  •