简体   繁体   中英

Javascript-Alert box

I am working on a single page application using angularJS which will work on Intranet. One of the requirement is after every 15 min i have to forcefully show a message to the user even if it he is working on some other program and once he click on OK button automatically that browser tab need to be shown. this functionality need to work on IE11/IE Edge/Chrome/Mozilla firefox. when i tried Javascript alert box with chrome it works as expected but when i tried it with firefox and IE it highlight the tab. unless user goes to that tab alert box doesn't shown up. Is there any workaround for this?
Is there any other good solution?

I have priority for IE/Edge. Thanks in advance.

I haven't really messed with AngularJS, but if it's just JS it should take normal JS. This code seems to work for me and I tested it and it worked for me (having it set to 1 second). The first block is the function to allow it to repeat, and the second block allows the code to initialize the loop.

function alertBoxTimer(){
    window.setTimeout(function() {
        alert('message goes here');
        alertBoxTimer();
    }, 900000);    //60*1000*15 = 900000 = 15mins
}

//initialize alert
alertBoxTimer();

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