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>