免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
JavaScript Kit- Event Object

Event Object

Last updated: Februrary 27th, 2006

The Event object keeps tracks of various events that occur on thepage, such as the user moving the mouse or clicking on the link, and allowsyou (the webmaster) to react to them.

The Event model and subsequent object is implemented differently in IE andNS/Firefox. Below we‘ll list the related properties and methods separately for the twodivergent models.

IE Event Object

In IE, the event object is accessed completely through the explicit object"window.event". It supports the following properties:

Properties

Properties Description NS Equivalent?
altKey, ctrlKey, shiftKey Boolean properties that indicate whether the Alt, Ctrl, and Shift keys were pressed at time of the event. Same.
button An integer indicating which mouse button was pressed or released, 1 = left, 2 = right, 4 = middle. If multiple buttons are pressed, the value is the sum of both buttons, such as 3 (1+2) for left and right. Same, but different return values.
cancelBubble Set to true to prevent the event from bubbling. stopPropagation()
clientX, clientY Returns the mouse coordinates at the time of the event relative to upper-left corner of the window. Example(s). Same.
fromElement, toElement For mouseover and mouseout events, these properties indicate the elements the mouse is leaving from and moving onto, respectively. relatedTarget
keyCode Property indicating the Unicode for the key pressed. Use String.fromCharCode(keyCode) to convert code to string. charCode
offsetX, offsetY Returns the mouse coordinates relative to the originating element. N/A
returnValue Set to false to cancel any default action for the event. preventDefault()
srcElement The element in which the event occurred on. target
type A string indicating the type of event, such as "mouseover", "click", etc. Same.

NS/Firefox Event Object

In NS6+, the event object is accessed by passing an event parameter into theevent handler function in question.

Properties

Properties Description IE Equivalent?
altKey, ctrlKey, metaKey, shiftKey Boolean properties that indicate whether the Alt, Ctrl, Meta, and Shift keys were pressed at time of the event. Same, though IE doesn‘t support "metaKey".
bubbles A Boolean value indicating whether or not the event bubbles. N/A
button An integer indicating which mouse button was pressed or released, 0 = left, 2 = right, 1 = middle. Slightly different in IE, as described above. Same, but different return values.
cancelable A Boolean value indicating whether or not the event can be canceled. N/A
charCode Property indicating the Unicode for the key pressed. Use String.fromCharCode(which) to convert code to string. keyCode
clientX, clientY Returns the mouse coordinates at the time of the event relative to upper-left corner of the window. Example(s). Same.
currentTarget The node that this event handler is currently being run on. N/A
eventPhase An integer value indicating which phase of the event flow this event is being processed in. One of CAPTURING_PHASE (1), AT_TARGET (2) or BUBBLING_PHASE (3). N/A
layerX, layerY Returns the mouse coordinates relative to the container element. (non standard). offsetX, offsetY
pageX, pageY Returns the left and top coordinates of event relative to the top left corner of the visible page. pageY would return the same value as "window.pageYOffset+e.clientY", for example. N/A
relatedTarget On a "mouseover" event it indicates the node that the mouse has left. On a "mouseout" event it indicates the node the mouse has moved onto. fromElement, toElement
screenX, screenY Returns the coordinates of the mouse relative to the screen when the event fired. N/A
target The node that the event originated from. srcElement
timestamp Returns the time (in milliseconds since the epoch) the event was created, for example, when a key was pressed (onkeypress). Not all events return a timestamp. N/A
type A string indicating the type of event, such as "mouseover", "click", etc. Same.
which NS4/NS6+ legacy property indicating the Unicode for the key pressed. Identical to "charCode", except this property works in NS4 as well.. keyCode

Methods

Methods Description IE Equivalent?
preventDefault() Set to true to cancel any default action for the event. returnValue
stopPropagation() Set to true to prevent the event from bubbling. cancelBubble

Examples

This example displays in the status bar the current coordinates of the mouseas it moves:

<script type="text/javascript">
function displaycoordIE(){
window.status=event.clientX+" : "+event.clientY
}
document.onmousemove=displaycoordIE
</script>

This example displays in the status bar the current coordinates of the mouseas it moves, in NS6+:FireFox

eg1:

<script type="text/javascript">
function displaycoordNS(e){
window.status=e.clientX+" : "+e.clientY
}
document.onmousemove=displaycoordNS
</script>


eg2:

<html>
<script>
function tt(e){
alert(e.screenX);
}
</script>
<body >
<input type="button" value="vv" onClick="tt(event)">
</body>
</html>

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
object - HTML元素
用javascript寫了個(gè)可以拖拽的小窗口程序
計(jì)算鼠標(biāo)所在位置的x,y坐標(biāo)的JavaScript腳本
mouse
定義一個(gè)可以移動(dòng)的div層 - 青山一點(diǎn)紅 - happay99 - 和訊博客
JavaScript Events
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服