Forum Moderators: open
<body onload=init() ...
<a href="#" id=a0>
...
function domouseout () {
//do stuff
}
function domouseover () {
//do stuff
}
function init(){
for (i=0;i<13;i++)
{
eval("a"+i+".onmouseover=domouseover");
eval("a"+i+".onmouseout=domouseout");
}
}
don't ask me why but the id has to start with a letter.
Anyway, here's an example I put together to give you an idea. If you want to use this you'd need to improve the sniffing and drop older browsers. The ie5 sniff needs to be on 1 line.
An interesting point, Opera 7 works with both methods. You gotta feel for those Opera programers :)
<html>
<head>
<title></title>
<script>ie5 = document.all && document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera')==-1?1:0
onload = function() {
links = document.getElementsByTagName('a')
links_length = links.length
for (var i=0; i<links_length; i++) {
if (ie5) {
links[i].attachEvent('onmouseover', href_on_mouse_over)
links[i].attachEvent('onmouseout', href_on_mouse_out)
} else {
links[i].addEventListener('mouseover', href_on_mouse_over, false)
links[i].addEventListener('mouseout', href_on_mouse_out, false)
}
}
output = document.getElementById('output-div')
}
function href_on_mouse_over() {
output.value = 'over'
}
function href_on_mouse_out() {
output.value = 'out'
}
</script>
</head>
<body>
<a href="some_page.htm">link 1</a>
<p></p>
<a href="other_page.htm">link 2</a>
<p></p>
<input type="text" id="output-div">
</body>
</html>
[msdn.microsoft.com...]