在关闭应用程序浏览器之前,应提示确认 [英] before closing the Application browser should prompt conformation
问题描述
我有一个小要求..
如果用户直接注销或注销,则他尝试关闭浏览器IE,然后单击"X"(IE或Firefox浏览器的右上角),然后我需要询问一个确认消息,例如您确定您要关闭吗?" ...
我在我的应用程序中使用母版页,并且尝试了以下事件:在我的母版页中"window.onbeforeunload"其工作正常,显示警报(构象)消息.但是,如果我按浏览器上的后退"按钮(IE或Firefox上的IE),那么它的触发方式(但不应)也可以完全满足我的要求. z让我知道........
我的意思是..如果Session("USerid")是活动的,或者它包含任何值,即
Session("USerid")="XXX"
在那一刻,如果用户尝试关闭浏览器(在IE或Firefox中单击"X"/关闭按钮浏览器),则会提示您您确定要关闭吗?". "h2_lin">解决方案
呼叫按钮注销事件对此代码进行了
< 脚本 类型 =" > window.onbeforeunload = function(){ if((window.event.clientX < 0) || (window.event.clientY< ; 0)) span> { span> document.getElementById('<% = btnLogoff.ClientID% >> ').click(); } }; < /script >
尝试一下
http://stackoverflow.com/questions/1631959/browser-window-close-event#1632004 [^ ]
http://stackoverflow.com/questions/1631959/browser-window-close-event#1632004 [^ ]
I have a small requirement..
if the user dint sign off or log off then he try''s to close the browser IE clicking on ''X'' (top right of IE or Firefox browser ) then i need to ask a conformation message like "Are you sure you want to close ?" ...
I am using Master page in my application and i tried the event : "window.onbeforeunload " in my master page its works fine, shows an alert(conformation) message. but if i press back button on the browser(IE on IE or Firefox) then also its firing(but it should not) is there any way to full fill my requirement ..I hope i had explained u clearly...if not pl z let me know........
what i mean to say is.. if the Session("USerid") is active or if it contains any value ie.
Session("USerid")="XXX"
at that moment if user trys to close the browse(click in ''X''/Close button browser either IE or Firefox ) it should give prompt a message "are u sure do u want to close?"..
call button log off event to this code
<script type="text/javascript"> window.onbeforeunload= function(){ if((window.event.clientX<0) || (window.event.clientY<0)) { document.getElementById('<%= btnLogoff.ClientID%>').click(); } }; </script>
Try This
http://stackoverflow.com/questions/1631959/browser-window-close-event#1632004[^]
http://stackoverflow.com/questions/1631959/browser-window-close-event#1632004[^]
这篇关于在关闭应用程序浏览器之前,应提示确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!