
javascript如何获取页面的高度和宽度
5个回答
展开全部
strInfo+=\r\n网页可见区域高:+document.body.clientHeight;
strInfo+=\r\n网页可见区域宽:+document.body.offsetWidth+(包括边线的宽);
strInfo+=\r\n网页可见区域高:+document.body.offsetHeight+(包括边线的高);
strInfo+=\r\n网页正文全文宽:+document.body.scrollWidth;
strInfo+=\r\n网页正文全文高:+document.body.scrollHeight;
strInfo+=\r\n网页被卷去的高:+document.body.scrollTop;
strInfo+=\r\n网页被卷去的左:+document.body.scrollLeft;
strInfo+=\r\n网页正文部分上:+window.screenTop;
strInfo+=\r\n网页正文部分左:+window.screenLeft;
strInfo+=\r\n屏幕分辨率的高:+window.screen.height;
strInfo+=\r\n屏幕分辨率的宽:+window.screen.width;
strInfo+=\r\n屏幕可用工作区高度:+window.screen.availHeight;
strInfo+=\r\n屏幕可用工作区宽度:+window.screen.availWidth;
window.confirm(strInfo);
</script
-----------------------------------------------------------------------------------------
最近编程中发现html静态页面的开发可以使用
document.body.ClientHeight
来获得页面的高度,但asp.net的页面却无法这样获取,获取到的只是页面最小的高度,比如页面只有一个button,那么该js语句获得的就是24。
document.documentElement.OffsetHeight
----------------------------------------------------------------------------------------加上document.body.scrollLeft;
document.body.scrollTop;
x=document.body.clientWidth+document.body.scrollLeft;
y=document.body.clientHeight+document.body.scrollTop;若想得到整个页面的高度可以用
strInfo+=\r\n网页可见区域宽:+document.body.offsetWidth+(包括边线的宽);
strInfo+=\r\n网页可见区域高:+document.body.offsetHeight+(包括边线的高);
strInfo+=\r\n网页正文全文宽:+document.body.scrollWidth;
strInfo+=\r\n网页正文全文高:+document.body.scrollHeight;
strInfo+=\r\n网页被卷去的高:+document.body.scrollTop;
strInfo+=\r\n网页被卷去的左:+document.body.scrollLeft;
strInfo+=\r\n网页正文部分上:+window.screenTop;
strInfo+=\r\n网页正文部分左:+window.screenLeft;
strInfo+=\r\n屏幕分辨率的高:+window.screen.height;
strInfo+=\r\n屏幕分辨率的宽:+window.screen.width;
strInfo+=\r\n屏幕可用工作区高度:+window.screen.availHeight;
strInfo+=\r\n屏幕可用工作区宽度:+window.screen.availWidth;
window.confirm(strInfo);
</script
-----------------------------------------------------------------------------------------
最近编程中发现html静态页面的开发可以使用
document.body.ClientHeight
来获得页面的高度,但asp.net的页面却无法这样获取,获取到的只是页面最小的高度,比如页面只有一个button,那么该js语句获得的就是24。
document.documentElement.OffsetHeight
----------------------------------------------------------------------------------------加上document.body.scrollLeft;
document.body.scrollTop;
x=document.body.clientWidth+document.body.scrollLeft;
y=document.body.clientHeight+document.body.scrollTop;若想得到整个页面的高度可以用
展开全部
window.outerHeight 窗口总高度 和window.screen.availHeight一样
window.innerHeight 窗口可视区域高度
window.screen.height 显示器屏幕高度
另外:jquery获取高度
$(".thisCrumbs").height()
元素本身高度
$(".thisCrumbs").innerHeight()
元素高度+内边距
$(".thisCrumbs").outerHeight()
元素高度+内边距+边框
$(".thisCrumbs").outerHeight(true)
元素高度+内边距+边框+外边距
window.innerHeight 窗口可视区域高度
window.screen.height 显示器屏幕高度
另外:jquery获取高度
$(".thisCrumbs").height()
元素本身高度
$(".thisCrumbs").innerHeight()
元素高度+内边距
$(".thisCrumbs").outerHeight()
元素高度+内边距+边框
$(".thisCrumbs").outerHeight(true)
元素高度+内边距+边框+外边距
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
strInfo+=\r\n网页可见区域高:+document.body.clientHeight;
strInfo+=\r\n网页可见区域宽:+document.body.offsetWidth+(包括边线的宽);
strInfo+=\r\n网页可见区域高:+document.body.offsetHeight+(包括边线的高);
strInfo+=\r\n网页正文全文宽:+document.body.scrollWidth;
strInfo+=\r\n网页正文全文高:+document.body.scrollHeight;
strInfo+=\r\n网页被卷去的高:+document.body.scrollTop;
strInfo+=\r\n网页被卷去的左:+document.body.scrollLeft;
strInfo+=\r\n网页正文部分上:+window.screenTop;
strInfo+=\r\n网页正文部分左:+window.screenLeft;
strInfo+=\r\n屏幕分辨率的高:+window.screen.height;
strInfo+=\r\n屏幕分辨率的宽:+window.screen.width;
strInfo+=\r\n屏幕可用工作区高度:+window.screen.availHeight;
strInfo+=\r\n屏幕可用工作区宽度:+window.screen.availWidth;
window.confirm(strInfo);
</script
strInfo+=\r\n网页可见区域宽:+document.body.offsetWidth+(包括边线的宽);
strInfo+=\r\n网页可见区域高:+document.body.offsetHeight+(包括边线的高);
strInfo+=\r\n网页正文全文宽:+document.body.scrollWidth;
strInfo+=\r\n网页正文全文高:+document.body.scrollHeight;
strInfo+=\r\n网页被卷去的高:+document.body.scrollTop;
strInfo+=\r\n网页被卷去的左:+document.body.scrollLeft;
strInfo+=\r\n网页正文部分上:+window.screenTop;
strInfo+=\r\n网页正文部分左:+window.screenLeft;
strInfo+=\r\n屏幕分辨率的高:+window.screen.height;
strInfo+=\r\n屏幕分辨率的宽:+window.screen.width;
strInfo+=\r\n屏幕可用工作区高度:+window.screen.availHeight;
strInfo+=\r\n屏幕可用工作区宽度:+window.screen.availWidth;
window.confirm(strInfo);
</script
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
网页可见区域宽:document.body.clientWidth
网页可见区域高:document.body.clientHeight
网页可见区域宽:document.body.offsetWidth(包括边线的宽)
网页可见区域高:document.body.offsetHeight(包括边线的宽)
网页正文全文宽:document.body.scrollWidth
网页正文全文高:document.body.scrollHeight
网页可见区域高:document.body.clientHeight
网页可见区域宽:document.body.offsetWidth(包括边线的宽)
网页可见区域高:document.body.offsetHeight(包括边线的宽)
网页正文全文宽:document.body.scrollWidth
网页正文全文高:document.body.scrollHeight
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只能得到宽度,不能得到页面的高度,宽度是window.width
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询