在特定时间后加载网址 [英] load a url after a specific amount of time

查看:58
本文介绍了在特定时间后加载网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址,我需要在一段特定的时间后打开它。

I have a single url that I need to open it after a specific amount of time.

我认为这可以使用js / jquery完成,我看到它工作方式如下:我打开用里面的js代码创建的页面,url在新标签页中自动加载,5分钟后,在新标签页或之前打开的同一标签页中打开相同的网址。
这是我正在努力的一个技巧,问题是我在js / jquery中不太了解这就是为什么我需要你的帮助。

I think this can be done using js/jquery and I see it working like this: I open the page created with the js code inside and the url loads automatic in a new tab and after 5 minutes this same url is opened in a new tab or in the same tab that was previously opened. It's a trick I am working on and the problem is that I don't know much in js/jquery that's why I need your help.

你可能问我:嘿,这个代码会每5分钟打开一个新标签,这样你就会有很多运行,你确定你需要这个吗?...我说是的,这就是我需要的,一个新标签单个网址每5分钟一次。

You might ask me: Hey, this code will open a new tab each 5 minutes so you'll have a lot of them running, are you sure you need this?.. and I say yes, that's what I need, a new tab for a single url each 5 minutes.

谢谢。

推荐答案

你可以用 setTimeout()将等待指定的时间(ms)然后执行声明的函数。

You could use setTimeout() which will wait a specified amount of time (ms) then execute the declared function.

示例:

setTimeout(openUrl, 5000); // Wait 5 seconds

function openUrl(){

   window.open('http://google.com');

}

要对计时器重复操作,您可以使用 setInterval()

To repeat an action on a timer you can use setInterval()

setInterval(openUrl, 5000);

这篇关于在特定时间后加载网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆