Introduction to XML Events
By Micah Dubinko2005-04-22
Two Kinds of Events
Listing 1 shows some of the variation that's possible. It defines two event handlers, one for the load event, and one for the unload event. One is written in VBScript, and attached through a less-common technique involving extra attributes on the script element. The other is written in ECMAscript (see Resources).
Listing 1. Two kinds of events
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"When viewed in Microsoft Internet Explorer or another browser that supports VBScript, an alert box displaying "hello" appears upon loading the document. In nearly all browsers, "goodbye" appears upon closing the window or navigating to another page. To fully describe what's going on here, you need to understand DOM Events, currently specified by a W3C document entitled Document Object Model (DOM) Level 2 Events Specification (see Resources).
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Intrinsic Events</title>
<script event="onload" for="window" language="vbscript">
<!--
alert "hello"
-->
</script>
</head>
<body onunload="alert('goodbye')">
</body>
</html>
Tutorial Pages:
» Dynamic Documents with Less Script
» Two Kinds of Events
» How Events Work
» From Events to XML Events
» Conclusion
» Resources
First published by IBM DeveloperWorks
