window.event object details

sponsored links
1, event on behalf of the state of events, such as trigger event object element, the location and status of the mouse, press the button and so on. event object only in the course of events to be effective. event of certain attributes only makes sense for specific events. For example, fromElement and toElement attributes onmouseover and onmouseout events are only meaningful.

2, attributes:
altKey, button, cancelBubble, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX, screenY, shiftKey, srcElement, srcFilter, toElement, type, x, y

3, property details:

Property Name Description Value Description
altKey check the status of alt key is pressed when the alt key, a value of True False otherwise read-only
shiftKey check the status of shift key when the shift key pressed, the value is read only True False otherwise
ctrlKey check the ctrl key pressed state when the ctrl key, a value of True False otherwise read-only cases: (Click the button shows that a few special keys pressed state)
<input type="button" value=" Click on the "/>
function show () (
alert ("altKey:" + window.event.altKey
+ "\ NshiftKey:" + window.event.shiftKey
+ "\ NctrlKey:" + window.event.ctrlKey);
) </ Script>
keyCode detect keyboard event corresponding to the internal code can read and write, can be any code within a Unicode keyboard. If there is no trigger keyboard events, then the value is 0
Example: (press Enter for the next components are the focus of considerable press Tab key)
<input type="text" onKeyDown="nextBlur()"/>
<input type="text"/>
function nextBlur () (
if (window.event.keyCode == 13) / / Enter the code
window.event.keyCode = 9; / / Tab key code
</ Script>
srcElement return Object element triggered the event read-only cases: (click on the button when the display name value)
<input type="button" value=" Min " name=" Fujian "/>
<input type="button" value=" Gan " name=" Jiangxi "/>
function show () (
alert (;
</ Script>
x, y relative to the current mouse position px read-only browser
clientX, clientY the current mouse position relative to the page read px
offsetX, offsetY mouse relative to the current page in the location of a region px read-only
screenX, screenY position relative to the user px display read-only Description: When you click a button, get (x, clientX, offsetX, screenX) is easy to understand offsetX; IE window when you obtained by reduction (x, clientX, screenX) , you will understand screenX; When you position the div property to switch between absolute and relative, you will understand the difference between x and clientX.
returnValue set or check the return value from the event in the event the value of true is returned
false the default event source object can read and write operation was canceled example: Shield Right, Ctrl + n, shift + F10, F5 to refresh, backspace
function KeyDown () (
/ / Shield right, Ctrl + N, Shift + F10, F5 to refresh, backspace
if ((window.event.altKey) & &
((Window.event.keyCode == 37) | | / / Alt + arrow key ← shield
(Window.event.keyCode == 39))) (/ / screen Alt + arrow keys →
event.returnValue = false; / / prevent the use of ALT + the arrow keys to page forward or backward
if ((event.keyCode == 8) | | / / mask the Backspace key to delete
(Event.keyCode == 116) | | / / shield F5 key to refresh
(Event.keyCode == 112) | | / / screen refresh key F1 Chinese network alliance
(Event.ctrlKey & & event.keyCode == 82)) (/ / Ctrl + R
event.keyCode = 0;
event.returnValue = false;
if ((event.ctrlKey) & & (event.keyCode == 78)) / / screen Ctrl + N
event.returnValue = false;
if ((event.shiftKey) & & (event.keyCode == 121)) / / shield Shift + F10
event.returnValue = false;
if (window.event.srcElement.tagName == "A" & & window.event.shiftKey)
window.event.returnValue = false; / / shielding shift plus the left mouse button to open a new page
if ((window.event.altKey) & & (window.event.keyCode == 115)) (/ / screen Alt + F4
window.showModelessDialog ("about: blank ",""," dialogWidth: 1px; dialogHeight: 1px");
return false;)
Press the mouse button check button 0 no key
A left click
2 Press Right
3 left-right
4 Press the middle button
5, left click and the middle button
6, right-click and the middle button
7 by all the key only for onmousedown, onmouseup and onmousemove event. On the other events, no matter how the mouse state, have returned to 0 (such as onclick)
srcElement detection onmouseover and onmouseout event occurs, the mouse is read from the element Object
toElement onmouseover and onmouseout event detection, the mouse is read-only access to the element Object
return back to the event type name is not "on" as the prefix of the event name, for example, onclick event return type is the click
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of window.event object details

  • SUI-JavaScript rich UI library integration solution

    Introduction: SUI is not a class implementation of the UI, nor is it a standard set of UI markup language, it is just to help the existing UI frameworks (such as Ext, YUI like) to mark the way to the statement and the creation of UI. The names of these ta

  • ActiveMQ practice the road (four) ActiveMQ 4.x + JBoss 4.x MDP actual articles

    Keyword: ActiveMQ ActiveMQ practice the road (four) ActiveMQ 4.x + JBoss 4.x MDP actual articles At <<ActiveMQ Practice ( Three ) ActiveMQ 4.x +JBoss 4.x Consolidating articles >> which we compare in detail the ActiveMQ with JBoss integration

  • Using Rails Captcha plug-in, easy implementation Verification Code

    Simple Captcha Plugin Can help us easily in the Rails implementation of Verification Code function. In addition, he has the option to provide sufficient to meet the U.S. requirements for certification, the use of easy. Supported picture and digital authen

  • [Ask] Rest nested resources helper method

    (Novice, studying RestFul_Rails, rails 2.2.2) Nested resource definition is as follows: And in the project under the index view using the following code: Results page error: iterations_path undefined I would like to ask how are going on? The teaching ...

  • Use Ext JS to read the JsonReader complex object json

    Today was how to resolve the following complex json object to the difficult living over a long time .. did not find documentation how to read JsonReader Ways json object (possibly also because of their limited level of E the text did not correctly underst

  • EJB

    public transient int counter; / / transient property private String firstname; / / persistent property @ Transient String getLengthInMeter () (...) / / transient property String getName () (...) / / persistent property @ Basic int getLength () (...) / / p

  • Dynamic loading JS script four kinds of methods

    To achieve dynamic loading JS script has four kinds of methods: 1, direct document.write <script language="javascript"> document.write ( "<script src='test.js'> <\ / script>"); </ script> 2, dynamic scri

  • spring + hibernate + oracle9i to read and write CLOB

    Database-driven update classes12-9i.jar Hibernate modify the configuration of the following code <bean/> <bean Lazy-init="true"> <property name="nativeJdbcExtractor"> <ref local="nativejdbcExtractor"/>

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • The level Hibernate cache

    Hibernate cache level: (1) a cache is very short and the session life cycle consistent, also known as session-level cache-level cache or transaction-level cache (2) Ways of Supporting level cache: get (); load (); iterator (); only entity object cach ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries