我用下面的代碼捕獲window.onbeforeunload活動頁面卸載時:「未知異常」取消與「location.href」
window.onbeforeunload = function (evt)
{
if(checkIsDirty())
{
var message = 'If you continue your changes will not be saved.';
if (typeof evt == 'undefined')
{
//IE
evt = window.event;
}
if (evt)
{
evt.returnValue = message;
}
else
{
return message;
}
}
}
當我出現的確認點擊「取消」,我得到錯誤「未知異常」,調試器突出顯示以下內容:
onclick="location.href='/<WhicheverPageYouRequested>.aspx';
如果單擊確定,頁面會完全更改。爲什麼我得到這個錯誤,我該如何解決它?