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
    Jun 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool using multiple timers in one Window

    Hi. I am needing help with pop-up windows. I have a main form with a function in it that calls a pop-up tip from an array every 15 seconds. It continually
    changes the tip until the user clicks the "close" button. At this point, I want the
    pop-up box to close, wait 5 minutes, and reopen the pop-up. I know I need to
    put this code in the onclick event of the close button, but how do I code it?

    Here's my main window:

    <html>
    <head>
    <title>We Be Toys</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function showTips(){
    tips = window.open("tips.html", "TipsWin", "width=150, height=180")
    tipsTimer = setTimeout("tips.close()","14000")
    }
    //-->
    </script>
    </head>
    <body bgcolor="87CEF6">
    <h1 align ="center">--We Be Toys--</h1>

    <script language="JavaScript" type="text/javascript">
    <!--
    window.setInterval("showTips()", "15000")
    </script>
    <h2 align="center">Welcome to our Web Site! Thanks for stopping by.</h2>
    <p align="center"><img src ="yoyo.JPG" alt = "Yo-Yo Mamas" border="2"></p>
    </body>
    </html>

    here's my pop-up window:

    <html>
    <head>
    <title>Handy Tips</title>
    <script language="JavaScript" src ="tips.js"></script>
    </head>
    <body bgcolor="C2E3F6">
    <div align=center>
    <script language="JavaScript" type="text/javascript">
    document.write("<b>Tip:<br><br>"+randomTips()+"<br>")
    </script>
    <form>
    <input type ="button" value = "Close" onClick= self.close()>
    </form>
    </div>
    </body>
    </html>


    Thanks very much.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try this:

    <script language="JavaScript" type="text/javascript">
    <!--

    function reopen(){
    setTimeout('showTips',5000)
    }

    function showTips(){
    tips = window.open("tips.html", "TipsWin", "width=150, height=180")
    tipsTimer = setTimeout("tips.close()","14000")
    }
    //-->
    </script>

    and in popup

    <input type ="button" value = "Close" onClick= "window.opener.reopen();self.close()">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    sorry
    function reopen(){
    setTimeout('showTips()',5000)
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You should check if opener is still open.
    <input type ="button" value = "Close" onClick= "if (opener&&!opener.closed)window.opener.reopen();self.close()">

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Viola--it works!

    Thanks SO much, both of you. It works!


  •  

    Posting Permissions

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