1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Javascript not working in netscape

Discussion in 'Firefox, Thunderbird & SeaMonkey' started by Mickeysoft, 2003/08/26.

Thread Status:
Not open for further replies.
  1. 2003/08/26
    Mickeysoft

    Mickeysoft Inactive Thread Starter

    Joined:
    2003/08/26
    Messages:
    2
    Likes Received:
    0
    The following code works fine in ie but not netscape. netscape seems to have problems working out that the text has 'wrapped' and so it extends the table size even though it does not have to. Any ideas why?

    <html>
    <body>

    <table border=1><tr><td>
    <script language= "JavaScript ">
    <!-- Begin

    news=[ "bla bla But not when the page updates using the innerHTML ",
    "And why the flashing when using the center tag?<br><center>Most strange!</center>"]

    function newsBar (name) {
    this.addCharacter=addCharacter
    if (document.getElementById)
    this.compatible=1
    else if (document.all)
    this.compatible=2
    else {
    this.compatible=0
    return
    }
    //document.write( "<div id=\" "+name+ "parent\" style=\ "TOP:0px;LEFT:0px;HEIGHT:100px;WIDTH:200px;\ "><span id=\" "+name+ "\ "></span></div> ")
    document.write( "<div id=\" "+name+ "\" style=\ "TOP:0px;LEFT:0px;HEIGHT:100px;WIDTH:200px;\ "></div> ")
    this.name=name
    this.line=0
    this.position=0
    if (this.compatible==1)
    this.newsbar=document.getElementById(name)
    if (this.compatible==2)
    this.newsbar=document.all[name]
    }

    function addCharacter() {
    if (!this.compatible) return
    if (this.position<=news[this.line].length) {
    while (news[this.line].substr(this.position,1)== "< ")
    this.position+=news[this.line].substr(this.position).indexOf( "> ")+1
    text=news[this.line].substr(0,this.position++)+ "_ "
    timer=50
    } else {
    text=news[this.line]
    timer=2000
    this.line<news.length-1?this.line++:this.line=0
    this.position=0
    }
    this.newsbar.innerHTML=text
    setTimeout(this.name+ ".addCharacter() ",timer)
    }

    newsbar=new newsBar( "newsbar ")

    // End -->
    </script>
    </td>
    <td>This text moves and should not</td>
    </tr>
    </table>

    <script language= "JavaScript ">
    <!-- Begin
    newsbar.addCharacter()
    // End -->
    </script>

    </body>
    </html>
     
  2. 2003/08/26
    Ramona

    Ramona Geek Member Alumni

    Joined:
    2001/12/31
    Messages:
    7,481
    Likes Received:
    2

  3. to hide this advert.

Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.