I have this javascript method that needs to run in the background
window.setInterval(function(){
validateCaseStatus();
}, 3000);
On the same page I have a button that asks the user if he wants to submit uploaded documents. But I noticed when the popUp msg(alert) is up the script on the page wont run.
Is there a way to keep the script running?
I use this method to check if the case status is changed and disable window.onbeforeunload.
My question is if theres a way I can keep the script above running even when a popUp alert is shown.
//cancels onbefore close popup when docs are submitted
function validateCaseStatus(){
caseStatus = sforce.apex.execute("IFAP_WebService","CheckCaseStatus", {!$caseId});
if (caseStatus == "Uploaded" || caseStatus == "Submitted")
{
submitted = true;
window.onbeforeunload = null;
validateCaseStatus = null;
}
}
Try using WebWorkers. It’s a new html5 concept, and requires a bit more work, but they are very easy to understand and very helpful. See https://developer.mozilla.org/en-US/docs/DOM/Using_web_workers?redirectlocale=en-US&redirectslug=Using_web_workers http://ejohn.org/blog/web-workers/ and http://www.html5rocks.com/en/tutorials/workers/basics/