我想知道是否有办法在JQuery中找出浏览器窗口是否有可见的滚动条?
这是我正在使用的代码:
var hContent = $("body").height();
var hWindow = $(window).height();
if(hContent>hWindow) {
$('#scroll-top').fadeIn(250);
}
else {
$('#scroll-top').fadeOut(250);
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都非常感谢,谢谢
使用以下功能.
function checkScrollBar() {
var hContent = $("body").height(); // get the height of your content
var hWindow = $(window).height(); // get the height of the visitor's browser window
// if the height of your content is bigger than the height of the
// browser window, we have a scroll bar
if(hContent>hWindow) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9479 次 |
| 最近记录: |