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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"global" mouseover

Status
Not open for further replies.

Rydel

Programmer
Feb 5, 2001
376
CZ
I have identical mouseover for all of my links (it takes the title attribute of the anchor tag and sets a form field with its value). I achieve this by adding the following code to each link:
onmouseover="myHandler(this)"
the problem is that I have many links. Is there a way to compress the code by setting some global property that makes all mouseovers invoke myHandler with this parameter?
Thanks in advance. The sample of the script acutally can be found on my home page (below, in the signature) ---
---
 
thanks a lot, jaredn. that could be an option. although my question was a bit different: i was curious about the possiblity to set global event handlers for a whole page.

sorry to bother you, but there was one more problem: netscape didn't seem to recognize the attribute "title" of the achnor tag. is it me screwing something up or it is just netscape (as often times before) fails to comply with the specs? ---
---
 
netscape is godawful. it probably doesn't support title. one thing you could do on your page, is rely on event bubbling (ie is easy, you'd have to check how to do it with mozilla - here's a faq on it, but I'll give you an example anyways - faq216-425 ). If you place all your links inside a table, you can do something like this (simple example):

<script>

function handleMouseOver()
{
var el = window.event.srcElement;
if(el.tagName==&quot;A&quot;)
{
disp.innerText = el.title
}
}

function handleMouseOut()
{
var el = window.event.srcElement;
if(el.tagName==&quot;A&quot;)
{
disp.innerText = ''
}
}

</script>

<table onmouseout=&quot;handleMouseOut()&quot; onmouseover=&quot;handleMouseOver()&quot;>
<tr>
<td><a title=&quot;wow&quot; href=&quot;#&quot;>Event Bubbling is neat</a></td>
</tr>
<tr>
<td><a title=&quot;oh my&quot; href=&quot;#&quot;>Event Bubbling is cool</a></td>
</tr>
</table>
<div id=&quot;disp&quot;></div> jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top