[英]Can javascript detect when scrollbars are unavailable (i.e. on mobile browsers)?
I've got a javascript-based Scrolling Widget Thingy™. 我有一个基于JavaScript的Scrolling Widget Thingy™。 One of the things it does is create a fixed height div
and gives it overflow: auto
. 它要做的一件事是创建一个固定的高度div
并给它overflow: auto
。
Alas on mobile Safari (and other mobile browsers) overflow: auto;
mobile在移动Safari(和其他移动浏览器)上overflow: auto;
doesn't show a scrollbar. 不显示滚动条。 Any content below "the fold" can only be found by accident. 折痕以下的任何内容只能偶然发现。
Is there a way to detect this in javascript, without resorting to browser detection? 有没有办法在不使用浏览器检测的情况下用javascript检测到这一点? eg 例如
if (there is a scrollbar) {
/* give me a fixed height and a scrollbar */
} else {
/* Do something more suited to this situation */
}
I can only think of resorting to dirty tricks: 我只能想到诉诸于肮脏的把戏:
overflow: auto
设置框overflow: auto
... given that there's actually a way to measure the inner size, scrollbar excluded. ...鉴于实际上有一种测量内部尺寸的方法,不包括滚动条。
It's a scary algorithm anyway, hundreds of things can go wrong... Consider it just an idea. 无论如何,这是一个令人恐惧的算法,成百上千的事情可能会出错……考虑一下这只是一个想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.