當我的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