Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you use onMouseOver on text?

Status
Not open for further replies.

cathl

Technical User
Aug 4, 2000
18
0
0
GB
I am trying to call a javascript function when the mouse goes over a piece of text in the browser but it isn't working.
I am using:
<a href=# onMouseOver=&quot;openIt(0)&quot;>Home</a>
where openIt is a javascript function.
Can anyone tell me why this won't work (in ie and ns) and if there's a solution other than putting an image in place of the text?
Any help greatly appreciated.
 
Try to put alert at the beginning of the
function so u'll know if the program reaches the function
or not.

I see no probelm with the way u wrote the event.

Exp.:
<html>
<head>
<script language=&quot;Javascript&quot;>
<!--
function functionName(x)
{alert(x);
}
//-->
</script>
</head>

<body>

<a href=&quot;#&quot; onMouseOver=&quot;functionName('text')&quot;>alert the text</a>
</body>
</html>
 
an other solution is to put your text between a span or a div - more logical than a href !
<span onmouseover=&quot;javascript:eek:penit(0)&quot;>blah blah</span>
it's ie4+ &amp; ns6+ only tho :-/
 
cathl, I think too that u should focus
on the function, and not on the href syntax.
Give us the link to check it if u can't find the problem yourself.
 
Thanks - I have now found the problem. It was in the function. I have put the text between a span too as suggested.
Thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top