查看: 1021|回复: 5
|
Web Browser 的 refresh button
[复制链接]
|
|
我想问这里的大大,当我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....
|
|
|
|
|
|
|
|
发表于 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
|
显示全部楼层
- window.onbeforeunload = function(event)
- {
- var ans = confirm("are you sure");
-
- if(ans == true)
- {
- window.location.href = 'logout.aspx';
- }
- else
- {
- alert('You clicked cancel');
- }
- }
复制代码 |
|
|
|
|
|
|
|
发表于 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>
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|