CSS/hover
Hi,
I am using the following to make my link change color when the mouse hovers over it:
a:active {color:blue}
a:link {color:blue}
a:hover {color:red}
This works great in IE, but not in NS. Anyone know how to do the same think easily in NS? Thanks.
bob
AndyB posted this at 01:11 — 12th February 2001.
They have: 344 posts
Joined: Aug 1999
hover is not supported by NS4.xx I think it is supported by NS6.
Mark Hensler posted this at 06:31 — 12th February 2001.
He has: 4,048 posts
Joined: Aug 2000
cross-browser solution
<a href="blah.html" style="color: 0000ff" onMouseOver="style.color='ff0000';" onMouseOut="style.color='0000ff';">blah</a>
This will make a blue hyperlink that turns red when you hover over it.
Mark Hensler
If there is no answer on Google, then there is no question.
Bob posted this at 17:16 — 12th February 2001.
They have: 117 posts
Joined: Feb 2000
Mark,
Thanks for the reply, but this solution works great with IE, but still does not work with NS. In fact, I get an error message, "style is not defined". Any thoughts? Thanks again.
Bob
AndyB posted this at 18:18 — 12th February 2001.
They have: 344 posts
Joined: Aug 1999
try ommouseOver="this.style.color"='#rrggbb';"
Bob posted this at 18:37 — 12th February 2001.
They have: 117 posts
Joined: Feb 2000
Andy,
Thanks, but still no good. Stil works with IE, but not NS. This time I get an error, "this.style.color has no properties". Thanks.
Bob
Lanamedia posted this at 03:22 — 25th February 2001.
They have: 3 posts
Joined: Jan 2001
just another wee idea for you.
try using this order for the css elements
a:link {color:blue}
a:hover {color:red}
a:active {color:blue}
Bob posted this at 03:27 — 25th February 2001.
They have: 117 posts
Joined: Feb 2000
Lanmedia,
Thanks for trying, but that still does not work with NS.
Bob
Suzanne posted this at 07:50 — 25th February 2001.
She has: 5,507 posts
Joined: Feb 2000
First, the rules in CSS are in order of use:
a:link
a:active
a:visited
a:hover
And it must be in that order to work properly.
Seconding, a:hover doesn't work in Netscape 4.x -- it's not supported. But it is in Netscape 6.0 + and Opera 5.
Suzanne
Bob posted this at 12:05 — 25th February 2001.
They have: 117 posts
Joined: Feb 2000
Suzzanne,
Thanks! You think some day all browsers will be fully compatitble?
Bob
Lanamedia posted this at 12:15 — 25th February 2001.
They have: 3 posts
Joined: Jan 2001
Hi Suzanne,
The second part of your answer and possibly what Bob is most concerned about (regarding a:hover not working in Netscape) no doubt, is correct as it is well documented.
However, can you please supply information as to the certainty of the css order because I have found the one I posted above does work for me!
There is also a tutorial on this at http://www.thepattysite.com/dreamweaver/linkstyles.html
Link
Visited
Hover
Active
is the quoted and emphasised order here.
If you got time might be worth finding out what http://validator.w3.org/ have to say on the matter.
Why are there so many conflicting ideas/standards on the order??
Maybe We can clear up the confusion once and for all :=)
1 Love
http://www.lanamedia.com
http://www.activateme.co.uk
http://www.futuretrend.co.uk
AndyB posted this at 12:27 — 25th February 2001.
They have: 344 posts
Joined: Aug 1999
According to http://www.w3.org/TR/REC-CSS1#appendix-a (and where else would you look), the order is LINK, VISITED, ACTIVE. Hover isn't in that standard .. because it is not supported.
um ... seems to me that that's exactly what I said in the very first answer to this thread:)
edits to add: take at look at http://www.insidedhtml.com/tips/styles/ts31/page1.asp which discusses the Netscape issue and provides a gruesome work-around.
Bob posted this at 12:45 — 25th February 2001.
They have: 117 posts
Joined: Feb 2000
Andy,
I guess you're right - we should have stopped with your original answer! I also found that gruesome workaround for Netscape. I actually got it to work, but decided to bag it since it was so rediculously complex in order to do the same thing that CSS/IE does so simply. My Netscape users will have to be satisfied with a link that does not change color! Thanks again.
Bob
Mark Hensler posted this at 19:48 — 25th February 2001.
He has: 4,048 posts
Joined: Aug 2000
you got my JS code to work?
what was the problem?
(I only have NN6, nothing earlier, so I couldn't test it)
Bob posted this at 20:09 — 25th February 2001.
They have: 117 posts
Joined: Feb 2000
Mark,
No I didn't get your code to work. I was talking about the solution that AndyB had mentioned at:
http://www.insidedhtml.com/tips/styles/ts31/page1.asp
It works, but is very involved. I didn't think it was worth adding that complexity to my code.
Bob
Hugh Jass posted this at 23:51 — 25th February 2001.
They have: 12 posts
Joined: Oct 2000
Hi all,
I never used Netscape, so I can't confirm whether or not this works:
workarounddemo.htm
Text Rollovers: An Example - Doc JavaScript
<script LANGUAGE="JavaScript">
Dynamic HTML Lab, who came up with the idea for this script. Be sure to check out his interesting columns, and his great list of JavaScript-related links.
// -->
</script>
<script LANGUAGE="JavaScript" SRC="workaround.js"></script>
workaround.css
.item { color: blue }
.highlight { color: red }
workaround.js
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var NS4 = (bName == "Netscape" && bVer >= 4);
var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
function display(id, str) {
if (NS4 || IE4) { // if browser supports style sheets
if (NS4) { // if Navigator 4.0+
with (document[id].document) {
open(); // open document
write(str); // write to document
close(); // close document
}
} else { // Internet Explorer 4.0+
document.all[id].innerHTML = str; // "assign" to element
}
}
}
function swapClass(text, spName, urlName, oldName, clName, over) {
if (bVer < 4) { // old browser
return; // terminate the function
}
// create a new string for the link
// change the link's class to clName (it was oldName before)
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
}
Hugh
Mark Hensler posted this at 00:48 — 26th February 2001.
He has: 4,048 posts
Joined: Aug 2000
ahhhh
Adam Oberdorfer posted this at 02:45 — 26th February 2001.
They have: 383 posts
Joined: Sep 2000
Once you start using layers you might as well just use images. At least that way it will work in all browsers that support JavaScript.
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.