Requirement: I want to show alert message to user after 5 minutes and after 9 minutes after page loading
I use setTimeOut function .l…but it seems its throwing alerts repetitively. Is it a repetitive function ? Can you please suggest a solution to my requirement ?
setTimeOut should only fire once.
Here’s an example using jQuery:
$(document).ready(function() {
setTimeout(function(){alert("Fired after ten seconds");}, 10000);
setTimeout(function(){alert("Fired after twenty seconds");}, 20000);
});
In this example you should see two alert boxes (after ten and twenty seconds respectively).
Herew’s the same example ithout jQuery
setTimeout[COLOR=#009900]([/COLOR][COLOR=#003366][B]function[/B][/COLOR][COLOR=#009900]([/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900]{[/COLOR][COLOR=#000066]alert[/COLOR][COLOR=#009900]([/COLOR][COLOR=#3366CC]"Fired after ten seconds"[/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][COLOR=#009900]}[/COLOR][COLOR=#339933],[/COLOR] [COLOR=#CC0000]10000[/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR]
setTimeout[COLOR=#009900]([/COLOR][COLOR=#003366][B]function[/B][/COLOR][COLOR=#009900]([/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900]{[/COLOR][COLOR=#000066]alert[/COLOR][COLOR=#009900]([/COLOR][COLOR=#3366CC]"Fired after twenty seconds"[/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][COLOR=#009900]}[/COLOR][COLOR=#339933],[/COLOR] [COLOR=#CC0000]20000[/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR]
Note that the second alert may not fire if the person viewing the first alert checks the option to turn off JavaScript.
+1 for the reminder that jQuery is JavaScript.