警告我有一個按鈕:防止 '確認導航' 與window.location.href
<button type="button" class="btn btn-primary mt15 send-emails" name="SendEmails" value="true">Send Emails</button>
與方法:
$('.send-emails').click(function (e) {
// build data and other stuff
$.post('/leads/sendemails', data, function (data, status, xhr) {
alert('Emails have successfully been queued for sending.');
window.onbeforeunload = null;
window.location.href = '/Leads/Lead/' + @Model.LeadID;
}, 'json');
});
即使window.onbeforeunload = null;
我仍然得到彈出警告:
我如何避免這種情況?
請試試這個:'$(window).unbind();' –
工作正常!列出它作爲答案? –