Web Analytics Made Easy -
StatCounter Want to Delay Popup Window - Please Help! - CodingForum


No announcement yet.

Want to Delay Popup Window - Please Help!

  • Filter
  • Time
  • Show
Clear All
new posts

  • Want to Delay Popup Window - Please Help!

    Hi, I'm having some trouble with my javascript pop-up window. I tried several different ways to get the pop-up window with a html page that references a Shockwave Flash file to open, but could only get it to work by using the following code:

    <SCRIPT language="JavaScript1.2">
    function poponload()
    testwindow= window.open("trailer.html",
    <BODY BGCOLOR=#FFFFFF BACKGROUND="images/background.gif" OnLoad="javascript: poponload()" "preloadimages();">

    The page that I'm referring to can also be viewed at http://www.ruffidea.com. What I want to do is to set a delay so that the pop-up window doesn't open for at least 10 seconds. Can someone let me know what I can add to the script to make this possible???



  • #2
    try: window.setTimeout(expression/function, milliseconds)

    window.setTimeout(expression/function, milliseconds)

    This method is used to call a function or evaluate an expression after a specified number of milliseconds. If an expression is to be evaluated, it must be quoted to prevent it being evaluated immediately. Note that the use of this method does not halt the execution of any remaining scripts until the timeout has passed, it just schedules the expression or function for the specified time.

    The following example opens a new window with a 5 sec (5000 millisecond) delay using the setTimeout method to call the function openmywindow().

    between <head></head> tags insert
    function delay(){
    window.setTimeout("openmywindow();", 5000)}

    function openmywindow(){
    window.open("", "tinyWindow", 'width=150, height=110');
    document.write('here is some content');}

    change the <BODY> tag to <BODY onload="delay()">

    When the page loads it will wait 5 secs then load the new window then write 'here is some content' to it.

    I hope this assists you.

    - Andrew