Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript alert block page loads

My client wishes to show an alert when entering a web page.

However, an alert blocks further loading of the page until "Ok" is clicked, and the page needs to load in the background while the alert is displayed.

One solution would be to use a custom alert using HTML and CSS, but this is not answering the client's needs.

Is there a solution using 'core javascript' or jQuery to allow the page to load while the alert is displayed? Thanks.

like image 816
Dipesh Parmar Avatar asked Jun 04 '13 08:06

Dipesh Parmar


Video Answer


1 Answers

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?

like image 139
nadavge Avatar answered Oct 13 '22 23:10

nadavge