Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q133 How do you make a text link read "Naht S'wew?" and Then OnMouseOver change to "What's New?"?

You are here: irt.org | FAQ | JavaScript | Text | Q133 [ previous next ]

The following works in Netscape 4 and Explorer 4:

<html>
<head>

<script language="JavaScript"><!--
var dhtml = '', no = 0;
if (navigator.appVersion.charAt(0) == "4") {
    if (navigator.appVersion.indexOf("MSIE") != -1)
        dhtml = 'IE';
    else
        dhtml = 'NN';
}

function mover(object,text) {
    if (dhtml == 'IE') {
        eval(object + '.innerText = text');
    }
    else if (dhtml == 'NN') {
        eval('document.layers["' + object + 'b"].moveBelow(document.layers["' + object + 'a"])');
        eval('document.layers["' + object + 'b"].visibility="hide"');
        eval('document.layers["' + object + 'a"].visibility="show"');
    }
}

function mout(object,text) {
    if (dhtml == 'IE') {
        eval(object + '.innerText = text');
    }
    else if (dhtml == 'NN') {
        eval('document.layers["' + object + 'a"].moveBelow(document.layers["' + object + 'b"])');
        eval('document.layers["' + object + 'a"].visibility="hide"');
        eval('document.layers["' + object + 'b"].visibility="show"');
    }
}

function dLink(href,text,txet) {
    if (dhtml == 'IE')
        document.write('<a href="'+href+'" onMouseOut="mout(\'link'+no+'\',\''+txet+'\')" onMouseOver="mover(\'link'+no+'\',\''+text+'\')" id="link'+no+'">'+text+'<\/a>');
    else if (dhtml == 'NN')
        document.write('<layer name="link'+no+'a" visibility="hide"><a href="'+href+'" onMouseOut="mout(\'link'+no+'\')">'+text+'<\/a><\/layer><layer name="link'+no+'b"><a href="'+href+'" onMouseOver="mover(\'link'+no+'\')">'+txet+'<\/a><\/layer>');
    else
        document.write('<a href="'+href+'">'+text+'<\/a>');
    document.write('<br>');
    no+=1;
}
//--></script>

</head>
<body>

<script>
dLink('new.html','What\'s New?','Naht S\'wew?');
</script>

</body>
</html>

Feedback on 'Q133 How do you make a text link read "Naht S'wew?" and Then OnMouseOver change to "What's New?"?'

©2018 Martin Webb