How to add 5 seconds of wait in url see script?

I have a redirect url script or link to url script.
I want to add 5 seconds of wait and then redirect the url to the url I want.

 <script>
 var url_index = window.location.href.indexOf('url=');
 if (url_index != -1)
 {
    url_go = window.location.href;
    url_go = url_go.substring(url_index + 4);
    //document.write(url_go);
    window.location.href = url_go;
 }
 var $_ = function(x){if(!document.getElementById){return;} else{ return document.getElementById(x);}}
 </script>  

      

Output http://transistortechnology.blogspot.com url = http://imgur.com

When I open above the url it is automatically redirected, but I want to add a 5 second wait.

Is this possible in your script code.

I put this script in the blogger header section

+3


source to share


2 answers


See: Javascript - Wait 5 seconds for next line to execute
Based on this, the following should probably work:






 url_go = ""
 function doRefer() {
     var url_index = window.location.href.indexOf('url=');
     if (url_index != -1)
     {
        url_go = window.location.href;
        url_go = url_go.substring(url_index + 4);
        setTimeout(function () {window.location.href = url_go;}, 5000);
     }
 }
      



+1


source


Yes, it's pretty easy to do. You do this by calling setInterval. Below is the documentation on how to do this.



And here is some code as an example (from the site): setInterval(function(){alert("Hello")},3000);

0


source







All Articles