add window.status javascript to a:hover css pseudo-class?

B

Bob P.

Hi, basically what I'd like to do is suppress the action that causes
the URL to show up in the browser status bar when I roll over a
hyperlink. I know I could use the onmouseover event in each anchor
tag, but I'd rather be able to do it globally thru my stylesheet,
rather than having to futz with each link. Does anyone know a
solution for this? It seems like you could maybe add quick
window.status='blah' javascript or something to the a:hover
pseudoclass to control status bar behavior. Thanks.
 
T

Thomas 'PointedEars' Lahn

Bob said:
Hi, basically what I'd like to do is suppress the action that causes
the URL to show up in the browser status bar when I roll over a
hyperlink. [...]

No, you don't want to mess with the UA of your visitors.


PointedEars
 
G

Grant Wagner

Bob P. said:
Hi, basically what I'd like to do is suppress the action that causes
the URL to show up in the browser status bar when I roll over a
hyperlink. I know I could use the onmouseover event in each anchor
tag, but I'd rather be able to do it globally thru my stylesheet,
rather than having to futz with each link. Does anyone know a
solution for this? It seems like you could maybe add quick
window.status='blah' javascript or something to the a:hover
pseudoclass to control status bar behavior. Thanks.

No, you can't add Javascript to CSS, at least not in a cross-browser,
cross-platform way (I think IE supports "behaviours" in CSS, but it's
not supported in most other browsers).

Use the following code to set the onmouseover event for every <A> on the
page:

<body onload="setAllHrefOver(returnFalse);">:
<script type="text/javascript">
function returnFalse() { return false; }
function setAllHrefMOver(f, d, inLayer) {
// to minimize page size, rather then defining separate onmouseover
// events for every link on the page, any link without an existing
// onmouseover event is set by this function

if (!inLayer) {
d = document;
}

if (d) {

var i;

if (d.links) {
for (i = 0; i < d.links.length; i++) {
if (!d.links.onmouseover) {
d.links.onmouseover = f;
}
}
}

if (d.layers) {
for (i = 0; i < d.layers.length; i++) {
setAllHrefMOver(f, d.layers.document, true);
}
}
}
} // setAllHrefMOver()
</script>

It just occurred to me you could use the "d" parameter to determine if
you're in a layer or not, you don't really need the "inLayer" indicator.
I'm not sure why I did that way, I think I wanted to be explicit about
when the function has been called recursively.

Note also that this function could be modified to either be passed the
event, or you could make a copy of the function for the onmouseout or
other events. You can also use it to assign events to other elements at
run-time. If you want to use it for elements other then <A>, you'll want
to investigate whether recursing into layers is required.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top