這是事件處理程序我設置了一個按鈕:爲什麼document.location或window.location不能工作?
$('.tabsTD').on('click', 'a.finalSave', (function() {
var returnStatus= finalSave(this, location);
if (returnStatus) {
if ($(this).text() == "Save and Continue") {
sessionStorage.carePlanReload = "true";
sessionStorage.activeTab = $('#tabs').tabs("option", "active");
window.event.returnValue = false;
document.location.reload(false);
}
else if ($(this).text() == "Save and Close") {
window.event.returnValue = false;
document.location = "MemberHome.aspx";
//setTimeout(function() { document.location = "MemberHome.aspx"; }, 500);
//return false;
//$('#aRedirectToHome')[0].click();
return false;
}
} /*END if*/
}));
在else if
情況下,我需要重定向到「memberhome.aspx」,但似乎沒有任何工作。我也嘗試添加一個錨標記,如:
<a href="MemberHome.aspx" id="aRedirectToHome" style="display:none;">RedirectToHome</a>
,然後從else if
調用上的錨一次點擊,但事實證明這是一次失敗的嘗試。
請幫忙。
你能試試嗎? document.location.href =「window.location.protocol + window.location.host + MemberHome.aspx」; –
@LuongDinh請參閱我對第一個答案的評論,並且您錯誤地引用了上述評論 –