[英]jQuery get the document width and height excluding horizontal/vertical scrollbars
I have a piece of jQuery on my site that displays an overlay the full width and height of the window. 我的网站上有一块jQuery,可显示窗口的整个宽度和高度。 I have an issue in that if the overlay is closed (as there is an option to close it) I lose the vertical scroll bar from my window. 我有一个问题,如果关闭了叠加层(可以关闭它),则我的窗口会丢失垂直滚动条。 Is there a way to specify the width and height excluding any horizontal or vertical scrollbars? 有没有一种方法可以指定宽度和高度( 不包括任何水平或垂直滚动条)?
This is my code below, the jQuery will run as soon as the page loads. 这是我的下面的代码,jQuery将在页面加载后立即运行。
<div id="screen"></div>
$('#screen').css({ "display": "block",
opacity : 0.7,
"width" : $(document).width(),
"height" : $(document).height()
});
$('body').css({ "overflow" : "hidden" });
This works: 这有效:
$('#screen').css({ "display": "block",
opacity : 0.7,
"width" : $(document).width(),
"height" : $(document).height()
});
$('body').css({ "overflow" : "auto" });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.