javascript - Add timeout function to reveal modal with cookie -
I have successfully used this script to set up a jquery cookie that tells the site visitors that a model appears But only once per day.
& lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {// If the cookie does not exist then create it and show model if (! $ .cookie ('hereToday')) {// cookie Set it to end it. 1 day $ .cookie ('heretoday', true, {expires: 1}); // reveal call modal $ ('# subscribe'). Reveal ();}}); & Lt; / Script & gt; How can I add a timeout function to the script which will add some seconds delay before firing the modal?
You should use setTimeout function: & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {// If the cookie does not exist then create it and show model if (! $ .cookie ('hereToday')) {// cookie Set it to end it. Call in a modal var delay = 5000; // ms in 1 day $ .cookie ('heretoday', true, {expires: 1}); // ms, this means 5 seconds set timeout (function () ($ ( '#Subscribe'). Reveal ();}, Delay);}}}
Comments
Post a Comment