"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:41***********************@newsread2.arcor-online.net...
Targa wrote:
Im looking for a script that would cover all links on a page
without having to add code to each link.
I also know lots of people hate it when you do that but this is for
an application which requires IE5.5+ and there is no need for the user
to view the links.
Tested with IE 6:
Should work with IE 5.5 too.
Below works in Netscape 4, IE 4+, Opera 6+ and Mozilla:
function setAllHrefMOut(f, d, inLayer) {
if (!inLayer) {
d = document;
}
if (d) {
var i;
if (d.links) {
i = d.links.length;
while (i-- > 0) {
if (!d.links[i].onmouseout) {
d.links[i].onmouseout = f;
}
}
}
if (d.layers) {
i = d.layers.length;
while (i-- > 0) {
setAllHrefMOut(f, d.layers[i].document, true);
}
}
}
} // setAllHrefMOut()
Corresponding setAllHrefMOver() could be written as well, or modify the
current function to specify mouseover/mouseout.
Called using:
function myMouseOut() {
// do whatever
return true;
}
setAllHrefMOut(myMouseOut);
Yes, yes, I realized later that I didn't really need to pass "inLayer",
but I was concerned someone would see the method signature and do:
setAllHrefMOut(myMouseOut, document);
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq