问题描述
|
我是javascript和jquery的新手。我正在使用一些预制的东西放在我的网站上。
http://brainscuker.altervista.org/
当我单击链接向下滚动到锚点时,它最初会转到正确的位置,但不久之后,它将向上滚动。
在Firefox和Chrome上效果很好。
我正在使用的脚本是这个。
$(document).ready(function() {
$(\"a.who\").anchorAnimate()
});
jQuery.fn.anchorAnimate = function(settings) {
settings = jQuery.extend({
speed : 800
},settings);
return this.each(function(){
var caller = this
$(caller).click(function (event) {
event.preventDefault()
var locationHref = window.location.href
var elementClick = $(caller).attr(\"href\")
var destination = $(elementClick).offset().top;
$(\"html:not(:animated),body:not(:animated)\").animate({ scrollTop: destination},settings.speed,function() {
window.location.hash = elementClick
});
return false;
})
})
}
thx任何最终的帮助!
解决方法
window.location.hash在IE上存在错误。当前正在解决类似问题,必须使用scroll或scrollTo函数使其起作用。