は非ベンダー接頭辞プロパティを含むすべての可能なオプションをチェックし、jQueryのか、Modernizrなどのライブラリの依存関係を持っていないソリューションです:
function hasOverflowScrolling() {
var prefixes = ['webkit', 'moz', 'o', 'ms'];
var div = document.createElement('div');
var body = document.getElementsByTagName('body')[0];
var hasIt = false;
body.appendChild(div);
for (var i = 0; i < prefixes.length; i++) {
var prefix = prefixes[i];
div.style[prefix + 'OverflowScrolling'] = 'touch';
}
// And the non-prefixed property
div.style.overflowScrolling = 'touch';
// Now check the properties
var computedStyle = window.getComputedStyle(div);
// First non-prefixed
hasIt = !!computedStyle.overflowScrolling;
// Now prefixed...
for (var i = 0; i < prefixes.length; i++) {
var prefix = prefixes[i];
if (!!computedStyle[prefix + 'OverflowScrolling']) {
hasIt = true;
break;
}
}
// Cleanup old div elements
div.parentNode.removeChild(div);
return hasIt;
}
alert(hasOverflowScrolling());
(より大きい1200pxワイド画面で無タッチイベントのサポート )CSSプロパティ、 と幅広いデスクトップブラウザ推論テストをスクロールしてくださいあなたの質問に少し努力してください。 – Triode
可能重複:http://stackoverflow.com/questions/3343311/can-javascript-detect-when-scrollbars-are-unavailable-ie-on-mobile-browsersまた、参照してください:http://lostmonocle.com/post/870842095/geeky-stuff-using-jquery-to-check-if-scrollbars-are – Prescott
私はこのような何かを考えていたが、それを見つけるのが難しい:http:///stackoverflow.com/questions/3911866/how-to-detect-lack-of-positionfixed-in-a-generic-way – ackernaut