网站首页
高清电影
无损音乐
游戏攻略
电脑教程
破解资源
站长资源
软件下载
event.x,event.clientX,event.offsetX区别
(编辑:jimmy 日期: 2024/10/14 浏览:
2
)
x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。
clientX:相对于客户区域的x坐标位置,不包括滚动条,就是正文区域。
offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。
screenX:相对于用户屏幕。
测试代码一:
[code]
<html>
<head>
</head>
<script>
function reload(){
window.location.reload("https://www.jb51.net");
}
</script>
<body>
<table>
<TR><TD><input type="button" name="button1" value="button1" onclick="reload();"></TD><TD></TD></TR>
<TR><TD><input type="button" name="button2" value="button2" onclick="reload();"></TD><TD></TD></TR>
</table>
<input type="button" name="update" value="刷新" onclick="reload();">
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<input type="button" name="button" value="button" onclick="reload();">
</body>
</html>
<script>
function window.onbeforeunload()
{
alert('event.clientX='+event.clientX);//如果是鼠标点击“刷新”按钮,则跟鼠标点击时的位置有关
alert('event.offsetX='+event.offsetX);
alert('document.body.clientWidth='+document.body.clientWidth);
alert('event.clientY='+event.clientY);
alert('event.offsetY='+event.offsetY);
alert('event.altKey='+event.altKey);
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要退出本页吗?";
}else
{
alert("你在刷新");
}
}
</script>
[/html]
演示代码二:
Click here to show.
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
上一篇:
类似框架的js代码
下一篇:
二级域名转向类
最新资源
白嘉倩.1992-我有我【星工厂】【WAV+CUE】
黎明.2006-LOOKING【东亚唱片】【WAV+CUE】
群星.1986-国语金曲尽精英【瑞成】【WAV+CUE】
長渕剛《Blood》[FLAC/分轨][299.09MB]
群星《歌手2024 第4期》[320K/MP3][107.39MB]
群星《歌手2024 第4期》[FLAC/分轨][563.76MB]
RiffKitten-ChaosParade(2024)[24-44,1]FLAC
RuneKlakegg-Nattevandrer(2024)[24-96]\FLAC
赖冰霞.2006-金嗓典藏辑2IN1(南方金点系列)2CD【
群星.1988-国语金曲尽精英VOL.2【瑞成】【WAV+C
首页
音乐
电影
资源