javascript窗口宽高,鼠标位置,滚动高度

网页可见区域宽:document.body.clientWidth
网页可见区域高:document.body.clientHeight
网页可见区域宽:document.body.offsetWidth (包括边线的宽)
网页可见区域高:document.body.offsetHeight (包括边线的宽)
网页正文全文宽:document.body.scrollWidth
网页正文全文高:document.body.scrollHeight
网页被卷去的高:document.body.scrollTop
网页被卷去的左:document.body.scrollLeft
网页正文部分上:window.screenTop
网页正文部分左:window.screenLeft
屏幕分辨率的高:window.screen.height
屏幕分辨率的宽:window.screen.width
屏幕可用工作区高度:window.screen.availHeight
屏幕可用工作区宽度:window.screen.availWidth

function getmXY(e){//鼠标位置
if(!document.all){
this.x=e.pageX;
this.y=e.pageY;
}else{
this.x=document.body.scrollLeft+event.clientX;
this.y=document.body.scrollTop+event.clientY;
};
//滚动高度
if (self.pageYOffset) {
this.yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
this.yScroll = document.documentElement.scrollTop;
} else if (document.body) {// all other Explorers
this.yScroll = document.body.scrollTop;
};
//视窗尺寸
if (self.innerHeight) { // all except Explorer
this.winWidth = self.innerWidth;
this.winHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
this.winWidth = document.documentElement.clientWidth;
this.winHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
this.winWidth = document.body.clientWidth;
this.winHeight = document.body.clientHeight;
};
};
function getwininfo(e){
var windowinfo = new getmXY(e);
window.status = “鼠标X:”+windowinfo.x+“鼠标Y:”+windowinfo.y+“窗口宽:”+windowinfo.winWidth+“窗口高:”+windowinfo.winHeight+“滚动高度:”+windowinfo.yScroll;
};

你可能感兴趣的:(JavaScript,工作)