【发布时间】:2014-10-21 09:15:22
【问题描述】:
我有这个 JS:
$(document).ready(function () {
var scrollMenu = $("#list .side-nav"),
scrollMenuFixed = false;
$(window).scroll(function() {
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
if (scrolled > 200 && !scrollMenuFixed) {
scrollMenu.addClass("fixed");
scrollMenuFixed = true;
}
else if (scrolled <= 200 && scrollMenuFixed) {
scrollMenu.removeClass("fixed");
scrollMenuFixed = false;
}
});
});
它在 IE +9 FF 和 Chrome 等上运行良好。但在 IE9 中没有人知道这个问题吗?
注意:事件在页面加载时注册。
【问题讨论】:
-
尝试使用 jQuery
scrollTop()属性,因为它应该是跨浏览器兼容的:var scrolled = $(this).scrollTop();
标签: javascript jquery internet-explorer-9 compatibility