最近一段时间因为特殊原因,正在学习 html 相关技术,这个周末应该就可以结束啦。
本来想全屏点击,响应并且返回位置信息,结果发现不能响应,经过一番搜索,发现
1、可以给 body 添加 width 和 height ,然后点击就会响应时间;
2、添加方法
document.onmousedown = function(){alert('0');} // 加入这句的话,点击鼠标就能响应事件
代码如下:
html:
<body onmousedown="test1(event)" onmousemove="test1(event)" style="background-color: pink;">
<script language="javascript">
</script>
</body>~~~
css:
body {
width: 500px;
height: 400px;
/width: 100%;/
/height: 100%;/ 100%是不能够显示的
}~~~
js:
function test1(locati) {
//window.alert("OK!~");
document.writeln('x=' + locati.clientX + " y=" + locati.clientY);
}
// 这些事只需要其中的一个来验证就可以了
document.onmousedown = function (locati) {
//window.alert('x=' + locati.clientX + " y=" + locati.clientY);
//alert('0'); // 加入这句的话,点击鼠标就能响应事件
}
document.onmousedown = function(){alert('0');} // 加入这句的话,点击鼠标就能响应事件
document.onmousemove = function(){document.writeln("逗逗,大,")} //~~~