使用JavaScript或元标记自动刷新页面

I try to steer clear of modifying a page without the user triggering the change, much less automatically refresh or redirect a page. There are times when automatically refreshing the page is important, like when you pull up game play-by-play pages on NFL.com or ESPN.com. Whatever your reason for automatically refreshing the page, keep one thing in mind: auto-refresh only pages that have little interaction -- nothing more than a click.

我尝试避免在用户不触发更改的情况下修改页面,更不用说自动刷新或重定向页面了。 有时候,自动刷新页面很重要,例如在NFL.com或ESPN.com上拉逐个游戏页面时。 无论您是出于何种原因自动刷新页面,请记住一件事:仅自动刷新交互很少的页面-只需单击即可。

JavaScript方法 (The JavaScript Method)


var timer = null;
function auto_reload()
{
	window.location = 'http://domain.com/page.php';
}

	

META标签方法 (The META Tag Method)

The following refreshes the page every 30 seconds.

以下内容每30秒刷新一次页面。

<head>
<meta http-equiv="refresh" content="30" />
</head>

翻译自: https://davidwalsh.name/automatically-refresh-page-javascript-meta-tags

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值