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 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with "splashmessages"

    I am trying to create a small "splashmessage" page but I am having trouble with the "num" variable. It will go thru the document.write the first time, but after that I get an error that "num" is undefined.

    Any help would be greatly appreciated.

    ========================================= CODE =========================================

    <html>
    <head>
    <title>Untitled</title>

    <script language=javascript>

    //configure delay in miliseconds between each message (default: 5 seconds)
    var intervals=5000

    var splashmessage=new Array()
    var openingtags='<center><h1><font face="Arial">'
    splashmessage[0]='Message 1 goes here.'
    splashmessage[1]='Message 2 Line 1 goes here<br>Message 2 Line 2 goes here'
    splashmessage[2]='Message 3 goes here'
    var closingtags='</font></h1></center>'
    var num=0

    function splashMessages() {

    if(num<splashmessage.length){
    document.write(openingtags+splashmessage[num]+closingtags+"<br>"+num)
    num++
    document.write("<br>"+num)
    }
    setTimeout('splashMessages()',intervals)
    }

    </script>

    </head>

    <body onLoad="splashMessages()">
    <font>Test Text</font>
    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never call document.write() from an event handler. Period. The results are unpredictable. A loaded document's input stream is closed, and re-opening it is a crapshoot.

    Use innerHTML, or DOM.
    &nbsp;........ another wild guess ........


  •  

    Posting Permissions

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