简体   繁体   中英

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 . 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".

In jquery, there are plugins for this kind of dialogs like Jquery UI, or select on of theese:

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(); will ask the user about closing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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