关于浏览器和屏幕的坐标大全

<body onclick="Text()">

<script type="text/javascript">   
var strInfo="";
function Text(){
strInfo+=window.event.x; //设置或获取鼠标指针位置相对于父文档的 x 像素坐标
strInfo+="\n"+window.event.y;//设置或获取鼠标指针位置相对于父文档的 y 像素坐标。
strInfo+="<br>"+window.event.clientX;//设置或获取鼠标指针位置相对于窗口客户区域的 x 坐标,其中客户区域不包括窗口自身的控件和滚动条.
strInfo+="\n"+window.event.clientY;//设置或获取鼠标指针位置相对于窗口客户区域的 y坐标,其中客户区域不包括窗口自身的控件和滚动条.
strInfo+="<br>"+window.event.screenX;  //screenX 设置或获取获取鼠标指针位置相对于用户屏幕的 x 坐标。 
strInfo+="\n"+window.event.screenY;  //screenX 设置或获取获取鼠标指针位置相对于用户屏幕的 y 坐标。 
strInfo+="<br>"+window.event.offsetX;//offsetX 设置或获取鼠标指针位置相对于触发事件的对象的 x 坐标。
strInfo+="\n"+window.event.offsetY;//offsetX 设置或获取鼠标指针位置相对于触发事件的对象的 y坐标。
/*event.clientX返回事件发生时,mouse相对于客户窗口的X坐标,event.X也一样。但是如果设置事件对象的定位属性值为relative,event.clientX不变,而

event.X返回事件对象的相对于本体的坐标。*/ 
strInfo+="<br>"+document.body.scrollWidth;//上下滚动条高度距离屏幕左端的距离
strInfo+="\n"+document.body.scrollHeight;//屏幕内容距离窗口上端的距离
strInfo+="<br>"+document.body.scrollTop;//网页被卷去的高
strInfo+="\n"+document.body.scrollLeft;//网页被卷去的宽
strInfo+="<br>"+document.body.clientWidth;//网页可见区域的宽度(不会随着鼠标的变化而变化,不包括边框和滚动条);
strInfo+="\n"+document.body.clientHeight;//网页可见区域的高度(不会随着鼠标的变化而变化,不包括边框和滚动条);
strInfo+="<br>"+document.body.offsetWidth;//网页可见区域的高度(不会随着鼠标的变化而变化,包括边框和滚动条);
strInfo+="\n"+document.body.offsetHeight;//网页可见区域的高度(不会随着鼠标的变化而变化,包括边框和滚动条);
strInfo+="<br>"+window.screenTop;//网页正文部分上 有些浏览器要换成window.screenX
strInfo+="\n"+window.screenLeft;//网页正文部分左 有些浏览器要换成window.screenY
strInfo+="<br>"+window.screen.width;//返回屏幕分辨率的宽度
strInfo+="\n"+window.screen.height;//返回屏幕分辨率的高度
strInfo+="<br>"+window.screen.availWidth;//返回屏幕可用工作区的像素宽度(不包括工具栏)
strInfo+="\n"+window.screen.availHeight;//返回屏幕可用工作区的像素的高度(不包括工具栏)


document.write(strInfo);
}
</script>
</body>

 

 
 
posted @ 2016-06-08 15:09  ShirleyHe  阅读(1324)  评论(0编辑  收藏  举报