[Javascript] Text Rollover in Netscape and IE

Steve Vernon steve at extremewattage.co.uk
Thu Nov 21 15:48:59 CST 2002


Hiya,
    Most sources I can find do text rollover for a link, and I jsut wanna do
it for a span.

    My script is:

         <SCRIPT LANGUAGE="JavaScript">
   <!--
    var browser = "Null";

    if (document.all)
    {
     browser = "IE";
    }
    else if (document.layers)
    {
     browser = "OldNetscape";
    }
    else if (document.getElementById)
    {
       browser = "NewNetscape";
    }

    // alert(browser);

    function rollon()
    {
     if(browser == "Null") return;

     if(browser=="OldNetscape")
     {
      with (document["alterme"].document) {
            open ();
            write ("Friends");
            close ();}
     }
     else if(browser=="NewNetscape")
     {
      document.all("alterme").innerText = "<span>Friends</a>";
     }
     else
     {
      document.getElementById("alterme").innerText = "Friends";
     }


     }
    function rolloff()
    {
     if (!document.getElementById) return;
     var title = document.getElementById("alterme");
     title.style.color= '#000000';
     title.innerText = 'Friends';

     }

    // -->
  </SCRIPT>

    And what I want to alter is <span href="" class="title"
id="alterme">Click for friends</span>

    This works fine in IE but not in Netscape 7, also can someone give me a
clue please whether the old Netscape code works as well?

    Thanks!

    Steve




More information about the Javascript mailing list