开发者

How do I go to a link after 5 seconds in javascript

开发者 https://www.devze.com 2023-02-21 01:39 出处:网络
Ho开发者_高级运维w would I make it so after a certain amount of time, a script will link to lets say href=\"index.jpg\" rel=\"lightbox\" class=\"blah\";

Ho开发者_高级运维w would I make it so after a certain amount of time, a script will link to lets say href="index.jpg" rel="lightbox" class="blah";

Then soon after go to the next link after another 5 seconds etc..


You will want to use the setTimeout function to implement this:

Executes a code snippet or a function after specified delay.


If you want to do it once use setTimeout. if you want to do it over and over use setInterval

This example will call myfunc() after 5 seconds (5000 milliseconds)

setTimeout("myfunc()", 5000);

function myfunc()
{
   // do what you need to do here
}
0

精彩评论

暂无评论...
验证码 换一张
取 消