使用javascript / jquery在c#中关闭浏览器之前的警告 [英] warning before browser close in c# using javascript/jquery

查看:63
本文介绍了使用javascript / jquery在c#中关闭浏览器之前的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我只能在我的page.aspx.cs写一个脚本。

我是包括我的代码中的以下行

 $(window).on('  unload',function(){
alert(' 再见!' );
});





关闭浏览器后发出警报。所以,我正在使用



 $(window).on('  beforeunload',function(){
return ' 你确定!';
});





不工作

可以帮助我任何人,我想要在关闭浏览器之前发出警告,只有当按下右上方的红色十字按钮时才显示页面刷新或重定向到另一页。

请帮助我。

解决方案

(窗口).on(' unload',function(){
alert(' 再见!');
});





关闭浏览器后发出警报。所以,我正在使用



 


(窗口).on(' beforeunload',function(){
return ' 你确定!';
});





不工作

任何人都可以帮助我,我想要在关闭浏览器之前发出警告,它应该只显示在当页面刷新或重定向到另一页时,不会按下右上角的红色十字按钮。

请帮助我。


试试这个javascript函数: -



 <   script     type   =  text / javascript >  
var close = true;
window.onbeforeunload = function(){
if(close){
return希望你喜欢它。
}
}
函数unhook(){
close = false;
}
< / script >


hi,

I'm in a situation to write a script only in my page.aspx.cs
i'm including below lines in my code

$( window ).on('unload',function() {
  alert( 'Bye now!' );
});



its throwing an alert after closing my browser. so, i'm using

$( window ).on('beforeunload',function() {
  return 'Are you SURE!' ;
});



which is not working
could any one help me, i want a warning before closing my browser and it should be shown only when red cross button at top right is pressed not when page is refreshed or redirected to another page.
Help me Please.

解决方案

( window ).on('unload',function() { alert( 'Bye now!' ); });



its throwing an alert after closing my browser. so, i'm using


( window ).on('beforeunload',function() { return 'Are you SURE!' ; });



which is not working
could any one help me, i want a warning before closing my browser and it should be shown only when red cross button at top right is pressed not when page is refreshed or redirected to another page.
Help me Please.


try this javascript function:-

<script type="text/javascript">
    var close = true;
    window.onbeforeunload = function(){
    if (close) {
        return "Hope you like it."
    }
    }
    function unhook() {
    close=false;
    }
</script>


这篇关于使用javascript / jquery在c#中关闭浏览器之前的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆