Prototype Framework handles all cross browser compatibility issues and keeps you free from all trouble related to event management.
Prototype Framework provides Event namespace which is replete with methods, that all take the current event object as an argument, and happily produce the information you're requesting, across all major browsers.
Event namespace also provides a standardized list of key codes you can use with keyboard-related events. The following constants are defined in the namespace:
Key Constant | Description |
KEY_BACKSPACE | Represent back space key. |
KEY_TAB | Represent tab key. |
KEY_RETURN | Represent return key. |
KEY_ESC | Represent esc key. |
KEY_LEFT | Represent left key. |
KEY_UP | Represent up key. |
KEY_RIGHT | Represent right key. |
KEY_DOWN | Represent down key. |
KEY_DELETE | Represent delete key. |
KEY_HOME | Represent home key. |
KEY_END | Represent end key. |
KEY_PAGEUP | Represent page up key. |
KEY_PAGEDOWN | Represent page down key. |
<html>
<head>
<title>Prototype examples</title>
<script type="text/javascript"
src="/javascript/prototype.js">
</script>
<script>
// Register event 'click' and associated call back.
Event.observe(document, 'click', respondToClick);
// Callback function to handle the event.
function respondToClick(event) {
var element = event.element();
alert("Tag Name : " + element.tagName );
}
</script>
</head>
<body>
<p id="note"> Click on any part to see the result.</p>
<p id="para">This is paragraph</p>
<div id="division"> This is divsion. </div>
</body>
</html>
Methods | Description |
Returns the DOM element on which the event occurred. | |
Extends event with all of the methods contained in Event.Methods. | |
Returns the first DOM element with a given tag name, upwards from the one on which the event occurred. | |
Determines whether a button-related mouse event was about the "left" (primary, actually) button. | |
Registers an event handler on a DOM element. | |
Returns the absolute horizontal position for a mouse event. | |
Returns the absolute vertical position for a mouse event. | |
Stops the event's propagation and prevents its default action from being triggered eventually. | |
Unregisters an event handler. |
No comments:
Post a Comment