Move mouse over the link
below.
To initialize event handler for an object, use the function initEvents:
initEvents(element_id,event_name,event_handler);
For example
initEvents("linkDiv","mouseover","mOver");
Notice that the event is without 'on' at the beginning. The function returns the object whose id is "element_id". The code I wrote for the link above is quite simple:function init(){
// create the object and assign handler for 'onmouseover' event
var link = initEvents("linkDiv","mouseover","mOver");
//assign handler for 'onmouseout' event
initEvents("linkDiv","mouseout","mOut");
}// Event handlers
function mOver(e){
alert("mouseover!");
}function mOut(e){
alert("mouseout!");
}
The HTML is:<html>
<head>
<script type="text/javascript" src="../js/ua.js">alert("ua.js not loaded!"):</script>
<script type="text/javascript" src="../js/init_events.js">alert("init_events.js not
loaded!");</script>
<script type="text/javascript" >
... the code written above ...
</script>
</head><body onload="init()">
<!-- The element: -->
<div id="linkDiv" style="position:absolute;">
<a href="javascript:alert('clicked!')">Mouse over here!</a>
</div>
<!-- The end of the element --></body>
</html>
Jakub Holy 2002AD