您好,欢迎来到曲格情感。
搜索
您的当前位置:首页javascript获得网页窗口实际大小的示例代码_javascript技巧

javascript获得网页窗口实际大小的示例代码_javascript技巧

来源:曲格情感


javascript代码:
代码如下:
function get_page_size()
{
var re = {};
if (document.documentElement && document.documentElement.clientHeight)
{
var doc = document.documentElement;
re.width = (doc.clientWidth>doc.scrollWidth)?doc.clientWidth-1:doc.scrollWidth;
re.height = (doc.clientHeight>doc.scrollHeight)?doc.clientHeight:doc.scrollHeight;
}
else
{
var doc = document.body;
re.width = (window.innerWidth>doc.scrollWidth)?window.innerWidth:doc.scrollWidth;
re.height = (window.innerHeight>doc.scrollHeight)?window.innerHeight:doc.scrollHeight;
}
return re;
}
904 viewed 3 comment(s)

代码实例:
代码如下:




获取窗口大小
输出至两个文本框
document.form1.availHeight.value= re.width;
document.form1.availWidth.value= re.height;
return re;
}





getPageSize();
window.onresize=getPageSize;



Copyright © 2019- qugedi.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务