当我的event.value ==为/时,我需要从网址中删除#。 我有一个jquery.address的存储引用打开图像,当我关闭它我需要删除#标记因为这个原因窗口滚动顶部lighbox。JQuery.address如何从网址中删除#(javascript window.location删除#)
我成功的删除了#标记:window.location.href.slice(0,-1);但正如你可以在上面的代码中看到的那样,当页面加载时,不仅在我的事件之后导致url重写。
我如何链接此JavaScript只有当我完成发生时,在这个函数被称为olny当我关闭灯箱的方式。
我附上我的代码和评论。 谢谢大家
$.address.change(function(event) {
curLink = event.value;
if(curLink != '/') {
// here my stuff, jquery.address generates url with reference
// ex: mysite.com/cat/subcat/page.html#one
} else {
$('#element').animate({opacity:"0"},{duration:100, easing:"quartEaseOut", complete: function() {
// here I need to remove the hash only after the complete
// ex: mysite.com/cat/subcat/page.html# > mysite.com/cat/subcat/page.html
window.location.href.slice(0, -1);
$(this).hide();
}});
}
});
这是有史以来最简单的解决方案。谢谢。 – Luke 2013-03-28 06:36:57