Невозможно отменить привязку перед загрузкой в IE
Я использую OAF Framework, который автоматически связывает функцию с событием onbeforeunload (например, onbeforeunload="_savePageStateIE()"
).
Я использую приведенный ниже код unbind стандартного func и привязать пользовательский func. Но он работает во всех браузерах, кроме IE.
<html>
<script>
window.onbeforeunload=null;
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "You have attempted to leave this page.";
}
</script>
<body onbeforeunload="_savePageStateIE()">
<h1 style="color:red">Hello World</h1>
</body>
</html>
1 ответ
<body onload="myFunction()">
<!-- put html code here -->
</body>
function myFunction() {
var redirect = confirm("Redirect to url ?");
if (redirect == true) {
window.location.href = 'url'; //redirect to url.
}
}
Или должно быть так
var warning = true;
window.onbeforeunload = function() {
if (warning) {
return "You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your unsaved changes";
}
}
$('form').submit(function() {
window.onbeforeunload = null;
});
Я нашел верхний отсюда: - URL
Особенно для то есть..
<script>
$(window).on('beforeunload', function(){
return "This should create a pop-up";
});
</script>