Javascript Alert Block Page Loads
Solution 1:
You should run it through a setTimeout:
setTimeout(function() { alert('hello world'); }, 1);
This is shown here: Is there a JavaScript alert that doesn't pause the script?
Solution 2:
EDIT
see @FunKy's answer for a workaround in Firefox. (really interesting!)
Simple answer is no, it's not possible!
Reason is native alert()
dialog is UI blocking and javascript is a single thread language.
You have to use a customized dialog message.
But, if some ajax request are done just before blocking UI, when alert()
dialog is closed, the ajax response will/should be available. So, you still can make some ajax request just before showing alert.
Solution 3:
You can use a custom dialog box instead of an alert box (which block page load). For exemple, Jquery UI Dialog is easy to use (but there are many plugins which do exactly the same thing).
Post a Comment for "Javascript Alert Block Page Loads"