- var x = document.body.scrollLeft;
- var y = document.body.scrollTop;
- //获取屏幕宽度
- availWidth = parseInt(window.screen.availWidth);
- availHeight = parseInt(window.screen.availHeight);
- //获取可见区域 宽度 高度
- availWidth = parseInt(document.body.clientWidth);
- availHeight = parseInt(document.body.clientHeight);
- 可见区域高度:document.body.clientHeight
- 总高度:document.body.scrollHeight
- 可见区域宽度:document.body.clientWidth
- 总宽度:document.body.scrollWidth
- ==============================================================
- var getWindowInfo=function()
- {
- var scrollX=0,scrollY=0,width=0,height=0,contentWidth=0,contentHeight=0;
- if(typeof(window.pageXOffset)=='number')
- {
- scrollX=window.pageXOffset;
- scrollY=window.pageYOffset;
- }
- else if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
- {
- scrollX=document.body.scrollLeft;
- scrollY=document.body.scrollTop;
- }
- else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
- {
- scrollX=document.documentElement.scrollLeft;
- scrollY=document.documentElement.scrollTop;
- }
- if(typeof(window.innerWidth)=='number')
- {
- width=window.innerWidth;
- height=window.innerHeight;
- }
- else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
- {
- width=document.documentElement.clientWidth;
- height=document.documentElement.clientHeight;
- }
- else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
- {
- width=document.body.clientWidth;
- height=document.body.clientHeight;
- }
- if(document.documentElement&&(document.documentElement.scrollHeight||document.documentElement.offsetHeight))
- {
- if(document.documentElement.scrollHeight>document.documentElement.offsetHeight){
- contentWidth=document.documentElement.scrollWidth;
- contentHeight=document.documentElement.scrollHeight;
- }
- else
- {
- contentWidth=document.documentElement.offsetWidth;
- contentHeight=document.documentElement.offsetHeight;
- }
- }
- else if(document.body&&(document.body.scrollHeight||document.body.offsetHeight))
- {
- if(document.body.scrollHeight>document.body.offsetHeight)
- {
- contentWidth=document.body.scrollWidth;
- contentHeight=document.body.scrollHeight;
- }else{
- contentWidth=document.body.offsetWidth;
- contentHeight=document.body.offsetHeight;
- }
- }
- else
- {
- contentWidth=width;
- contentHeight=height;
- }
- if(height>contentHeight)
- height=contentHeight;
- if(width>contentWidth)
- width=contentWidth;
- var rect=new Object();
- rect.ScrollX=scrollX;
- rect.ScrollY=scrollY;
- rect.Width=width;
- rect.Height=height;
- rect.ContentWidth=contentWidth;
- rect.ContentHeight=contentHeight;
- return rect;
- }