...

View Full Version : Works in IE but not in Netscape.



florida
07-16-2002, 01:12 PM
This link changes color on mouseover and mouseout works in IE but not in Netscape browser. I
have the latest Netscape and IE browsers and my Javascript is enabled on both but why does the
below not work in Netscape????


<a
href="myfile.htm" onMouseOver="javascript:overAndOut(this);window.status='MyText...';return
true;"
onMouseOut="javascript:overAndOut(this);window.status='';return true;"
STYLE="font-size:8pt;">
CHANGE LINK TEXT COLOR ON MOUSE OVER HERE</a>




<script name="javascript">
function overAndOut(oEl) {
if (oEl.style.color == 'blue')
oEl.style.color = 'orange';
else oEl.style.color = 'blue';
}
</script>

requestcode
07-16-2002, 03:31 PM
Here is an example that will work in IE5+ and NS6+. It will not work in IE4 and NS4 version browsers, allthough it will not throw any errors. You just won't get the color change.


<html>
<head>
<title>Change Link Color</title>
<SCRIPT LANGUAGE="JavaScript">
function chgcolor(obj,lcolor)
{
if(document.getElementById)
{
whichone=obj.id
document.getElementById(whichone).style.color=lcolor
}
}
</SCRIPT>
<CENTER>
<H1>Link Effect Example</H1>
Run your mouse over the links to see them change color
</CENTER>
<a href="http://www.wsabstract.com" style="color:blue" id="mylink" onMouseOver="chgcolor(this,'red')" onMouseOut="chgcolor(this,'blue')">Website Abstraction</a>
</CENTER>
</body>
</html>

Vladdy
07-16-2002, 03:43 PM
For IE5+ NS6+ you would use CSS to accomplish the task
This goes to css file or <STYLE> element


.myLink:link
{color: blue;
}
.myLink:visited
{color: blue;
}
.myLink:hover
{color: red;
}

Add class attribute to any anchor element.


<A HREF="..." CLASS="myLink">....</A>

No JavaScript is needed. You can make your links change not only color but any other attribute you can specify in a style sheet.
If you want to have some fun with your visitors..... try this:


.myLink:link
{ position: static;
color: blue;
}
.myLink:visited
{color: blue;
}
.myLink:hover
{ position: absolute;
top: 100px;
left: 200px;
color: red;
}

:D :D :D

tamienne
07-16-2002, 03:48 PM
Try this..

http://www.dansteinman.com/dynduo/examples/textrollover1.html

florida
07-16-2002, 04:49 PM
Looks like I have Netscape 4.51 or 4.77.

I can not use CSS so please advise if I can get this to work in my version of Netscape???

Vladdy
07-16-2002, 05:11 PM
Catch up with time and upgrade.... you are not building your website for yourself (are you?) but for the world (95% of which uses CSS compliant browsers)....

tamienne
07-16-2002, 06:01 PM
The info in the link i provided seems to work for me. I tested it on NS 4.78

florida
07-16-2002, 06:46 PM
I assume I need CSS to do this with Netscape 4.78 version. Unfortunately I can not use CSS due to style guide 508 restrictions here. Anyone have any other ideas on how to get this working on Netscape with my current browser???

requestcode
07-16-2002, 07:36 PM
For Netscape 4 version browsers you can't use CSS to such as Vladdy's example to change the color of the link. What I have done in the past for NS4 is place the link within a div and rewrite the link when you mouse over and out. Not a very good way of doing it. I would suggest that you use Browser detection scheme's to detect which browser/version and if it is NS4 do nothing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum