检测页面是否有垂直滚动条? [英] Detect if a page has a vertical scrollbar?
本文介绍了检测页面是否有垂直滚动条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想要一些简单的JQ / JS来检查当前页面/窗口(不是特定元素)是否有垂直滚动条。
I just want some simple JQ/JS to check if the current page/window (not a particular element) has a vertical scrollbar.
Google搜索给了我的东西对于这个基本功能来说似乎过于复杂。
Googling gives me stuff that seems overly complex for just this basic feature.
如何做到这一点?
推荐答案
$(document).ready(function() {
// Check if body height is higher than window height :)
if ($("body").height() > $(window).height()) {
alert("Vertical Scrollbar! D:");
}
// Check if body width is higher than window width :)
if ($("body").width() > $(window).width()) {
alert("Horizontal Scrollbar! D:<");
}
});
这篇关于检测页面是否有垂直滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文