<script type="text/javascript">
$(document).ready(function(){
var winWidth = 0;
var winHeight = 0;
findDimensions();
function findDimensions() // 函数:获取尺寸
{
// 获取窗口宽度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
// 获取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
// 通过深入 Document 内部对 body 进行检测,获取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
}
$("form").before('<div style="height: '+winHeight*0.2+'px"></div>');
});
</script>
js 获取窗体宽度和高度 JavaScript
最新推荐文章于 2023-10-11 17:37:50 发布