[英]window.location not working with window.location.href?
我有這段代碼,
$('.editLayout #changeLayout').click(function() {
$('html').height($(document).height());
$('#fluidWrap').hide('scale');
$.ajax({
data: {
mainLayout: true
},
success: function() {
alert(window.location.href);
window.location = window.location.href;
}
});
return false;
});
當alert
返回時,我得到一個帶有哈希值的有效網址,例如:
http://www.example.com/edit#_layout
但是,即使頁面正常刷新,如果我按f5鍵,頁面也不會刷新。
有任何想法嗎?
嘗試
window.location.reload(true);
更新 (這里是Chrome的hacky解決方案)
setTimeout(function(){window.location.reload(true);},100)
更新哈希不會重新加載頁面,並且通過相同的標記將頁面href設置為包含哈希的href也不會刷新頁面。 嘗試這個:
alert(window.location.href);
window.location = window.location.href.split('#')[0];
嘗試
window.location.href = window.location.href;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.