Modernizr は優れていますが、サンプル テストposition: fixed
は完全ではありません。
- iOS 4 以下は
true
、サポートされていない間は返品されますposition: fixed
- Windows 上の Operaは、
false
サポートしている間に復帰しますposition: fixed
Modernizr テストに基づく別のテストを見つけましたが、iOS 検出が追加されています: https://gist.github.com/855078/109ded4b4dab65048a1e7b4f4bd94c93cebb26b8。今後の iOS 5 がposition: fixed
.
ブラウザのスニッフィングなしで iOS で修正された位置をテストする方法を見つけるのを手伝ってくれませんか?
// Test for position:fixed support
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());
var oldCssText = root.style.cssText;
root.style.cssText = 'padding:0;margin:0';
test.style.cssText = 'position:fixed;top:42px';
root.appendChild(test);
root.appendChild(control);
var ret = test.offsetTop !== control.offsetTop;
root.removeChild(test);
root.removeChild(control);
root.style.cssText = oldCssText;
if (fake) {
document.documentElement.removeChild(root);
}
return ret;
});