87,910
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<script>
var x =10000;
function clt(e)
{
x += e?e.clientX:window.event.clientX;
alert(x);
}
window.onload = clt;
</script>
</body>
</html>
HTMLEvents
不带clientX
要想获取
必须用MouseEvents
Table 17-3.
Event types Event type
Interface
B
C
Supported by/detail properties
abort
Event
yes
no
<img>, <object>
blur
Event
no
no
<a>, <area>, <button>, <input>, <label>, <select>, <textarea>
change
Event
yes
no
<input>, <select>, <textarea>
click
MouseEvent
yes
yes
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
error
Event
yes
no
<body>, <frameset>, <img>, <object>
focus
Event
no
no
<a>, <area>, <button>, <input>, <label>, <select>, <textarea>
load
Event
no
no
<body>, <frameset>, <iframe>, <img>, <object>
mousedown
MouseEvent
yes
yes
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
mousemove
MouseEvent
yes
no
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey
mouseout
MouseEvent
yes
yes
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, relatedTarget
mouseover
MouseEvent
yes
yes
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, relatedTarget
mouseup
MouseEvent
yes
yes
screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
reset
Event
yes
no
<form>
resize
Event
yes
no
<body>, <frameset>, <iframe>
scroll
Event
yes
no
<body>
select
Event
yes
no
<input>, <textarea>
submit
Event
yes
yes
<form>
unload
Event
no
no
<body>, <frameset>
DOMActivate
UIEvent
yes
yes
detail
DOMFocusIn
UIEvent
yes
no
none
DOMFocusOut
UIEvent
yes
no
none
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:95px;
height:20px;
z-index:1;
}
-->
</style>
</head>
<body>
<div id="Layer1"><a id="clicklink" href="#">click here</a></div>
<script>
var x =10000;
function clt(e)
{
x += e?e.clientX:window.event.clientX;
alert(x);
}
document.getElementById('clicklink').onclick = clt;
</script>
</body>
</html>
这样就没问题了,楼上那张表我看过(http://blog.csdn.net/Xviewee/archive/2007/05/11/1604562.aspx),当时没看明白,现在懂了些了 。