[Javascript] link status
Hassan Schroeder
hassan at webtuitive.com
Tue Dec 17 11:02:29 CST 2002
Cutter (JavaScript) wrote:
> Yes, I want to set a mouseover event for all links on the page. No, I do
> not want to include the mouseover in the link itself. I wanted to know
> if anyone had possibly done something like this using the links[] object
> of the document. Something like (though this doesn't do it...):
>
> <script>
> var d = document;
> for( var i = 0; i < d.links.length; i++ ){
> d.links[i].onmouseover = (window.status = '');
>
> </script>
Assignment to an event handler takes a reference to a function,
so you need something like this:
<script type="text/javascript">
function foo()
{
window.status = "";
return true;
}
function init()
{
var d = document;
for( var i = 0; i < d.links.length; i++ )
{
d.links[i].onmouseover = foo;
}
}
</script>
<body onload="init();">
// Until the page is loaded the links array will be empty , hence
// the running it via onload().
HTH!
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
More information about the Javascript
mailing list