Java Reference
In-Depth Information
Properties of the
event Object
Description
keyCode
Gets the Unicode keycode associated with the key that caused the event.
screenX
Indicates where in the browser window, in horizontal coordinates relative
to the origin in the screen coordinates, the mouse pointer was when the
event was generated.
screenY
Indicates where in the browser window, in vertical coordinates relative to
the origin in the screen coordinates, the mouse pointer was when the event
was generated.
shiftKey
Indicates whether the Shift key was pressed when the event was generated.
srcElement
Gets the element object that caused the event.
toElement
Gets the element object that the mouse pointer is entering.
type
Retrieves the event's name.
Let's revisit Example eight where you wrote a page to take advantage of the DOM event model and
change it to work in IE.
Try it Out Using the IE Event Model
Open your text editor and type the following. Feel free to copy and paste the elements within the body
and the style sheet from Example eight.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 12: Example 9</title>
<style type=”text/css”>
.underline
{
color: red;
text-decoration: underline;
}
</style>
<script type=”text/javascript”>
function handleEvent()
{
if (event.srcElement.tagName == “P”)
{
if (event.type == “mouseover”)
{
event.srcElement.className = “underline”;
}
Search WWH ::




Custom Search