【发布时间】:2015-02-27 12:12:27
【问题描述】:
在使用 IE10 时,我在尝试单击指向同一项目中网页的超链接时收到错误 JavaScript runtime error: Unable to get property 'top' of undefined or null reference,JavaScript 应该滚动到页面上的相应位置。
如果我使用任何其他浏览器,除了 IE,它可以在页面之间运行。但是,如果我在同一页面中使用相同的引用,它将在所有浏览器中上下滚动,但在离开页面时不会在 IE 中滚动。
链接
<li><a href="index.html#home_section">Home</a></li>
我使用的是jquery.nav.js 3.0.0 版,页面在var offset = $(target).offset().top; 处中断。
任何帮助将不胜感激:-)
【问题讨论】:
-
这有帮助吗?
scrollTo: function(target, callback) { var offset = $(target).offset().top; $("html, body").animate({ scrollTop: offset }, this.config.scrollSpeed, this.config.easing, callback); }, -
完整代码可在
https://github.com/davist11/jQuery-One-Page-Nav获取
标签: javascript jquery html internet-explorer internet-explorer-10