Question

Je trouve cet extrait:

(function( cn, url ) { if( navigator.cookieEnabled && !new RegExp( "(^|\\s|\\;)" + cn + "=1(\\;|\\s|$)").test( document.cookie ) ) { document.cookie = cn + '=1'; location.assign( url ); } })( "thisSession", "splash.html" );

Source: http://wcdco.info/tF

Comment je pourrais ajouter un délai, laisse dire 1 minute?

Était-ce utile?

La solution

En Javascript il y a la fonction setTimeout () pour cela.

Fenêtre setTimeout () Méthode

Fenêtre objet Définition et utilisation

La méthode setTimeout () appelle une fonction ou évalue une expression après un nombre spécifié de millisecondes.

Conseil:. 1000 ms = 1 seconde

<script>
    function doit(cn, url) {
        if (navigator.cookieEnabled && !new RegExp("(^|\s|\;)" + cn + "=1(\;|\s|$)").test(document.cookie)) {
            document.cookie = cn + '=1'; location.assign(url);
        }
    }

    window.setTimeout(doit("thisSession", "splash.html"), 60 * 1000);
</script>

http://www.w3schools.com/jsref/met_win_settimeout.asp

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top