...

View Full Version : Resolved dynamic mouseover by tagName/className



fuzzy1
08-12-2008, 06:47 PM
Hey All, I'm pretty sure this ought to work, but for the life of me I can't figure why it doesn't...:confused:

links = document.getElementsByTagName('a');
for (i=0;i< links.length;i++){
if((links[i].className=='listViewThLinkS1')&&(links[i]!='javascript:void(0);')){
alert(links[i]);//returns href values of apropriate 4 links, BUT...
links[i].onmouseover=alert('foo'); // THIS alerts 'foo' onload and then error
}
}WTFO???
EXAMPLE IN CONTEXT (sort of)

<a href="{ORDER_BY}last_name" class="listViewThLinkS1">{MOD.LBL_LIST_SUBJECT}</a>
<a href="{ORDER_BY}last_name" class="listViewThLinkS1">{MOD.LBL_LIST_CONTACT}</a>
<a href="{ORDER_BY}status" class="listViewThLinkS1">{MOD.LBL_LIST_STATUS}</a>
<a href="{ORDER_BY}date_sent" class="listViewThLinkS1">{MOD.LBL_LIST_DATE_SENT}</a>
<script>
links = document.getElementsByTagName('a');
for (i=0;i< links.length;i++){
if((links[i].className=='listViewThLinkS1')&&(links[i]!='javascript:void(0);')){
//alert(links[i]);//alerts the 4 link href values, BUT...
links[i].onmouseover=alert('foo');//alerts 'foo' one time(though not on mouseover), then error
}
}
</script>

fuzzy1
08-12-2008, 07:33 PM
AHA!
replacing

links[i].onmouseover=alert('foo');WITH...

links[i].onmouseover=function(){alert('foo');};
WORKS! Though I'm not quite sure why...:confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum