screenX 事件属性

返回上一级

HTML DOM 的 screenX 事件属性返回事件发生时鼠标指针相对于屏幕的水平坐标

语法

event.screenX

浏览器支持

Yes Yes Yes Yes Yes

范例

显示事件发生时鼠标指针的坐标

<script>
function coordinates(event){
    x=event.screenX
    y=event.screenY
    alert("X=" + x + " Y=" + y)
}
</script>
<body onmousedown="coordinates(event)">
<p>在文档中点击某个位置。消息框会提示出指针相对于屏幕的 x 和 y 坐标</p>
</body>

运行范例 »

返回上一级

JavaScript 参考手册

关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.