Javascript and rollovers in Netscape 6 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Javascript and rollovers in Netscape 6

Hi,

I've written a test script to change the styles of some text links on a rollover, however, I can't make it work in Netscape 6+.
I feel that I've done the tricky bit in making it work in Netscape 4.7, but the few things I've tried in Netscape 6 don't work. Every time I try to attach the code to this message and then preview, the html code gets interpreted by the browser and it doesn't all display. Is there a way I can attach the code without this happening? Alternatevely, if you'd like to help out I could email the code to you
Thanks in advance

f



Rollovers Example for Web Page


.item { color: blue; text-decoration: none; background-color: yellow; }
.highlight { color: red; text-decoration: underline; background-color: green; }









var bVer = parseInt(navigator.appVersion);
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function display(id, str) {

if (isNS4) { // if Navigator 4.0+
with (document[id].document) {

open(); // open document
write(str); // write to document
close(); // close document
}
} else if (isIE4) { // Internet Explorer 4.0
document.all[id].innerHTML = str; // "assign" to element
} else if (isIE5) { // Internet Explorer 5.0
document.all[id].innerHTML = str; // "assign" to element
} else if (isNS6) { // Netscape 6+

var thing = document[id].document;

document.open();
document.write(str);
document.close();

}

}

function swapClass(text, spName, urlName, oldName, clName, over) {
if (bVer < 4) { // old browser
return; // terminate the function
}

// create a new string for the link
var str = "";
} else {
// replace onMouseOut with onMouseOver
// replace false with true
str += " onMouseOver="swapClass('" + text + "', '" + spName +
"', '" + urlName + "', '" + clName +
"', '" + oldName + "', true)">";
}
str += text + "
";
display(spName, str); // update the code
}







Netscape

Microsoft



Sign In or Register to comment.