admin管理员组文章数量:1326299
How can I disable dialog alert and close the website in window.onbeforeunload
?
window.onbeforeunload = function() {
var isVisible = $('#submitbtn').is(':visible');
if(isVisible==true){
return null;
}else{
return 'you havent close';
}
How can I disable dialog alert and close the website in window.onbeforeunload
?
window.onbeforeunload = function() {
var isVisible = $('#submitbtn').is(':visible');
if(isVisible==true){
return null;
}else{
return 'you havent close';
}
Share
Improve this question
edited Dec 8, 2016 at 17:41
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Dec 6, 2016 at 8:05
kennethlaw126 kennethlaw126kennethlaw126 kennethlaw126
231 silver badge3 bronze badges
1 Answer
Reset to default 7return undefined;
to prevent dialog while window.onbeforeunload
Demo:-
window.onbeforeunload = function(e) {
var isVisible = $('#submitbtn').is(':visible');
if (isVisible == true) {
$(window).unbind();
return undefined;
//is there any way to disable dialog alert and close the website??
} else {
return 'you havent close';
}
};
$('#hidebtn').on("click",function(){
$('#submitbtn').toggle();
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="httpp://google.">Leave page</a>
<input type="button" id="submitbtn" value="You will not get the dialog untill i am visible" />
<input type="button" id="hidebtn" value="hide/show" />
本文标签: javascriptHow to disable dialog alert and close the website in windowonbeforeunloadStack Overflow
版权声明:本文标题:javascript - How to disable dialog alert and close the website in window.onbeforeunload? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742207077a2433015.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论