Main Points

Unobtrusive Javascript Example 3

This page calls a Javascript file. The onmouseover events which the div in red responds to is in the Javascript file, not this html document. However, in this test, not only does the red div respond to an onmouseover event, but now it responds to an onmouseout event as well. An extra event handler is called.

//Call the Breakaway function when user mouses out of div1
document.getElementById("div1").onmouseout=Breakaway;

When you mouse over the red div, the blue div is reset from display:none to display:block and it appears. When you mouse out of the red div, the blue div's display is reset to none and it disappears. The Breakaway function includes the functionality to turn off the div in the unobtrusive script.

document.getElementById("div2").style.display="none";
Me
Me Too!
Skip to Main Points