佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1021|回复: 5

Web Browser 的 refresh button

[复制链接]
发表于 2-4-2014 04:33 PM | 显示全部楼层 |阅读模式
我想问这里的大大,当我click webbrowser's refresh then it will prompt msg and redirectly to another page, may i know how to do? i want do in javascript in asp.net. i have try use window.location.href it can't work. This method samething like CIMB website after you login then when you press refresh it will log you out....

回复

使用道具 举报


ADVERTISEMENT

发表于 2-4-2014 05:55 PM | 显示全部楼层
window.onbeforeunload = function(event)
{
        return confirm("Confirm refresh");
};

//jQuery
$(window).bind("beforeunload", function(){
        return confirm("Do you really want to refresh?");
});
回复

使用道具 举报

 楼主| 发表于 2-4-2014 06:14 PM | 显示全部楼层
thanks for your reply. but i put like that

        window.onbeforeunload = function (event) {
            if (confirm("asdf")) {
                //window.open("logout.aspx");
                window.location = "logout.aspx";
            }

        };

it doesn't refresh to the logout page.....
回复

使用道具 举报

发表于 2-4-2014 10:28 PM | 显示全部楼层
  1. window.onbeforeunload = function(event)
  2. {
  3.      var ans = confirm("are you sure");
  4.      
  5.      if(ans == true)
  6.      {
  7.           window.location.href = 'logout.aspx';
  8.      }
  9.      else
  10.      {
  11.           alert('You clicked cancel');
  12.      }
  13. }
复制代码
回复

使用道具 举报

发表于 2-4-2014 11:13 PM | 显示全部楼层
server side script 来的, session 的东西。。。。javascript client 可以disable。
回复

使用道具 举报

 楼主| 发表于 3-4-2014 08:36 AM | 显示全部楼层
weiloon12345 发表于 2-4-2014 10:28 PM

我试了,还是不能redirectly to logout.aspx.... it will prompt the alert message after i click “OK" it still remain same page.. I using IE10 window 7

<script type="text/javascript">
        window.onbeforeunload = function (event) {
            var ans = confirm("are you sure");

            if (ans == true) {
                window.location.href = "logout.aspx";
            }
            else {
                alert("cancel");
            }
        }


    </script>
</head>

<body>
    <form id="form1" runat="server">  
    <div>        
        <asp:Button ID="Button1" runat="server"
            Text="Button" />
    </div>
    </form>
</body>

回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 30-8-2025 05:41 PM , Processed in 0.123111 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表