Netscape difficulties with script to change link color
I am trying to get the code for NS to work for a font for a link changer. I have on in IE that works and have something to detect them, and the page runs fine in IE. WHen I bring it into NS, NS doesn't bring up the page, and it screws up NS so that I can't use it again until I reboot. Anyway, here is the NS code...why won't this work??
<script language="JavaScript">
<!--//
function show(layerid) {
if(document.layers)
layerid.visibility="show"
}
function hide(layerid){
if(document.layers)
layerid.visibility="hide"
}
//-->
</script>
<script language="Javascript">
var linky1 = "SCAHPERD";
var linky2 = "SCAPES";
var linky3 = "SCARE";
var linky4 = "SCDA";
var texty1 = "About SCAHPERD";
var texty2 = "SCAPES";
var texty3 = "SCARE";
var texty4 = "SCDA";
var somethingy1 = "<span style='visibility:hidden'><layer id='text1white' visibility='show' onMouseover='show(text1navy);hide(text1white)'><A HREF='";
var somethingy2 = ".html'><span style='TEXT-DECORATION: none; color: white; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy3 = "</center></span></a></layer><layer id='text1navy' visibility='hide' onMouseout='hide(text1navy);show(text1white)'><A HREF='";
var somethingy4 = ".html'><span style='TEXT-DECORATION: underline; color: navy; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'>";
var somethingy5 = "</span></a></span><br>";
document.write(somethingy1 + linky1 + somethingy2 + texty1 + somethingy3 + linky1 + somethingy4 + texty1 + somethingy5);
document.write(somethingy1 + linky2 + somethingy2 + texty2 + somethingy3 + linky2 + somethingy4 + texty2 + somethingy5);
document.write(somethingy1 + linky3 + somethingy2 + texty3 + somethingy3 + linky3 + somethingy4 + texty3 + somethingy5);
document.write(somethingy1 + linky4 + somethingy2 + texty4 + somethingy3 + linky4 + somethingy4 + texty4 + somethingy5);
</script>
Moderate at JavaScriptCity Forums
AndyB posted this at 01:40 — 13th March 2000.
They have: 344 posts
Joined: Aug 1999
Add document.close() after all those document.writes should solve the NS problem
That's a tip I got just yesterday when I experienced exactly the same - flawless with IE and hung up with Netscape.
Arielladog posted this at 02:53 — 13th March 2000.
They have: 122 posts
Joined: Jun 1999
sad to report that that didn't work. I tried adding a document.open() thing, but that didn't work either. I am trying to get the effect of changing the link color and other attributes in netscape. IE I can do with CSS. Here is the whole code I have done. I have the NS thing working without the document.write things. That would add a lot to my code though if I had to do this, so I devised a "plan" that would help with this so it wasn't as long a script. It doesn't seem to work though. Here is the code that I originally got this from. I then, modified it to work propperly for my situation, then, I arranged it to a new format with about one twelveth the coding. Here is where I got it originally from
<html>
<head>
<title>Changing Text Color in Netscape</title>
<script language="JavaScript">
<!--//
function show(layerid) {
if(document.layers)
layerid.visibility="show"
}
function hide(layerid){
if(document.layers)
layerid.visibility="hide"
}
//-->
</script>
</head>
<body bgcolor="black">
<!-- When the mouse is over the layer the layers will switch giving the appearance of changing
colors. I had to use a SPAN tag to hide the layers from IE becasue IE ignores the <layer> tag
and just displays the text of both layers -->
<span style="visibility:hidden">
<layer id="text1white" visibility="show" onMouseover="show(text1red);hide(text1white)">
<h1><font color="white">Put your mouse over the text</font></h1>
</layer>
<layer id="text1red" visibility="hide" onMouseout="hide(text1red);show(text1white)">
<h1><font color="red">Put your mouse over the text</font></h1>
</layer>
</span>
</body>
</html>
Here is my coding for the page.
<script language="JavaScript">
<!--//
function show(layerid) {
if(document.layers)
layerid.visibility="show"
}
function hide(layerid){
if(document.layers)
layerid.visibility="hide"
}
//-->
</script>
<STYLE>
A.NAV { TEXT-DECORATION: none; color: white; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt}
A.NAV:hover { TEXT-DECORATION: underline; color: navy; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt}
a.links { font-size: 14pt; font-style: normal; font-weight: bold; text-decoration: underline}
body { font-family: "Times New Roman", Times, serif; font-size: 12pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #000000; text-decoration: none}
</STYLE>
</head>
<script language="Javascript">
var linky1 = "SCAHPERD";
var linky2 = "SCAPES";
var linky3 = "SCARE";
var linky4 = "SCDA";
var texty1 = "About SCAHPERD";
var texty2 = "SCAPES";
var texty3 = "SCARE";
var texty4 = "SCDA";
var something1 = "<p ALIGN='center'><A class='NAV' HREF='";
var something2 = ".html'>";
var something3 = "</a></p><br>";
var somethingy1 = "<span style='visibility:hidden'><layer id='text1white' visibility='show' onMouseover='show(text1navy);hide(text1white)'><A HREF='";
var somethingy2 = ".html'><span style='TEXT-DECORATION: none; color: white; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy3 = "</center></span></a></layer><layer id='text1navy' visibility='hide' onMouseout='hide(text1navy);show(text1white)'><A HREF='";
var somethingy4 = ".html'><span style='TEXT-DECORATION: underline; color: navy; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'>";
var somethingy5 = "</span></a></span><br>";
</script>
<script language="javascript">
IE = (navigator.appVersion.indexOf("MSIE"));
NS = (navigator.appName=="Netscape");
if (IE) {
document.open();
document.write(something1 + linky1 + something2 + texty1 + something3);
document.write(something1 + linky2 + something2 + texty2 + something3);
document.write(something1 + linky3 + something2 + texty3 + something3);
document.write(something1 + linky4 + something2 + texty4 + something3);
document.close();
}
if (NS) {
document.open();
document.write(somethingy1 + linky1 + somethingy2 + texty1 + somethingy3 + linky1 + somethingy4 + texty1 + somethingy5);
document.write(somethingy1 + linky2 + somethingy2 + texty2 + somethingy3 + linky2 + somethingy4 + texty2 + somethingy5);
document.write(somethingy1 + linky3 + somethingy2 + texty3 + somethingy3 + linky3 + somethingy4 + texty3 + somethingy5);
document.write(somethingy1 + linky4 + somethingy2 + texty4 + somethingy3 + linky4 + somethingy4 + texty4 + somethingy5);
document.close();
}
</script>
Moderate at JavaScriptCity Forums
tazman posted this at 03:32 — 13th March 2000.
They have: 99 posts
Joined: May 1999
I cant tell from your post, you may be doing this already, but make sure that the document.write commands are performed within the <body></body> tags of the document. You may perform them within a <head> function if you call the function from the body.
If it helps, great, if you are already doing it...sorry...
Tazman
Arielladog posted this at 04:34 — 13th March 2000.
They have: 122 posts
Joined: Jun 1999
I was fooling around with this, and I discovered that for the NN part of this script, if I remove all of the document.writes but one, it works...why???
Moderate at JavaScriptCity Forums
Arielladog posted this at 01:24 — 14th March 2000.
They have: 122 posts
Joined: Jun 1999
Here is the very ironic part. I will post a script that works in NS and a script that doesn't...when I add the extra document.write() it hangs.
here is the script that works:
<html><head>
<script language="JavaScript">
<!--//
function show(layerid) {
if(document.layers)
layerid.visibility="show"
}
function hide(layerid){
if(document.layers)
layerid.visibility="hide"
}
//-->
</script>
</head>
<body>
<script language="Javascript">
var linky1 = "SCAHPERD";
var linky2 = "SCAPES";
var linky3 = "SCARE";
var linky4 = "SCDA";
var texty1 = "About SCAHPERD";
var texty2 = "SCAPES";
var texty3 = "SCARE";
var texty4 = "SCDA";
var something1 = "<p ALIGN='center'><A class='NAV' HREF='";
var something2 = ".html'>";
var something3 = "</a></p><br>";
var somethingy1 = "<span style='visibility:hidden'><layer id='text1white' visibility='show' onMouseover='show(text1navy);hide(text1white)'><A HREF='";
var somethingy2 = ".html'><span style='TEXT-DECORATION: none; color: white; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy3 = "</center></span></a></layer><layer id='text1navy' visibility='hide' onMouseout='hide(text1navy);show(text1white)'><A HREF='";
var somethingy4 = ".html'><span style='TEXT-DECORATION: underline; color: navy; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy5 = "</center></span></a></span><br>";
document.write(somethingy1 + linky1 + somethingy2 + texty1 + somethingy3 + linky1 + somethingy4 + texty1 + somethingy5);
document.close();
</script>
</body></html>
Here's the one that hangs NS
<html><head>
<script language="JavaScript">
<!--//
function show(layerid) {
if(document.layers)
layerid.visibility="show"
}
function hide(layerid){
if(document.layers)
layerid.visibility="hide"
}
//-->
</script>
</head>
<body>
<script language="Javascript">
var linky1 = "SCAHPERD";
var linky2 = "SCAPES";
var linky3 = "SCARE";
var linky4 = "SCDA";
var texty1 = "About SCAHPERD";
var texty2 = "SCAPES";
var texty3 = "SCARE";
var texty4 = "SCDA";
var something1 = "<p ALIGN='center'><A class='NAV' HREF='";
var something2 = ".html'>";
var something3 = "</a></p><br>";
var somethingy1 = "<span style='visibility:hidden'><layer id='text1white' visibility='show' onMouseover='show(text1navy);hide(text1white)'><A HREF='";
var somethingy2 = ".html'><span style='TEXT-DECORATION: none; color: white; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy3 = "</center></span></a></layer><layer id='text1navy' visibility='hide' onMouseout='hide(text1navy);show(text1white)'><A HREF='";
var somethingy4 = ".html'><span style='TEXT-DECORATION: underline; color: navy; font-family :Verdana, Arial, Helvetica, sans-serif; font-size: 12pt'><center>";
var somethingy5 = "</center></span></a></span><br>";
document.write(somethingy1 + linky1 + somethingy2 + texty1 + somethingy3 + linky1 + somethingy4 + texty1 + somethingy5);
document.write(somethingy1 + linky2 + somethingy2 + texty2 + somethingy3 + linky2 + somethingy4 + texty2 + somethingy5);
document.close();
</script>
</body></html>
the only difference is that extra document.write()..now any other suggestions on why this happens?
Moderate at JavaScriptCity Forums
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.