简体   繁体   English

如果确认消息空闲则强制关闭JavaScript中的浏览器

[英]If confirm message idle force to close browser in javascript

i have a confirm message which is showing when page is idle for some time in javascript . 我有一条确认消息,当javascript中页面闲置一段时间后会显示该消息。 The confirm pop up came once the session time out. 会话超时后,弹出确认对话框。 At that time if we give any response to the confirmation pop up it will do the corresponding process. 那时,如果我们对确认弹出窗口做出任何响应,它将执行相应的过程。 My requirement is if we are not giving any response means i need to force the browser to close.. can anybody help me on this? 我的要求是,如果我们没有给出任何答复,则意味着我需要强制浏览器关闭..有人可以帮我吗?

window.setTimeout('checkIfContinue()', 5*1000);

var sFlag=0;

function checkIfContinue() 
  {
    window.setTimeout('idleTime()', 5*1000);

    if(sFlag == 0)
    {
        sFlag = 1;           
        if(confirm("Your Session Expired!. Do you wish to continue?")) 
        {          
          window.setTimeout('checkIfContinue()', 5*1000);  //start the timer again 
          sFlag = 0;    
        } 

         else  
         {
         // logout
        }
    }
} 

This is the query which i used to call the pop up after session time out. 这是我在会话超时后用来调用弹出式窗口的查询。 I need to close the browser when no responses given to the responses.. 没有响应时,我需要关闭浏览器。

I believe that in this case you'll need to use some other than system dialog. 我相信在这种情况下,您需要使用系统对话框以外的其他工具。

Eg showing a DIV with the question and buttons, so you'll be able to close the window even with opened "dialog". 例如显示带有问题和按钮的DIV,因此即使打开“对话框”,您也可以关闭窗口。

In jquery, there are plugins for this kind of dialogs like Jquery UI, or select on of theese: 在jquery中,有一些用于此类对话框的插件,例如Jquery UI,或在theese中选择on:

http://choosedaily.com/1178/15-jquery-popup-modal-dialog-plugins-tutorials/ http://choosedaily.com/1178/15-jquery-popup-modal-dialog-plugins-tutorials/

Also remember, that the browser window can be closed by script only when it was opened by the script. 还要记住,仅当脚本打开浏览器窗口时,才可以通过脚本关闭浏览器窗口。 Otherwise the function window.Close(); 否则函数window.Close(); will ask the user about closing. 将询问用户有关关闭的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM