Products
GG网络技术分享 2025-03-18 16:17 0
第一种:
今天给大家分享三种网页刷新的办法,通过JS代码就可以简单的实现,首先是第一种,直接看代码:
location.reload();
只要绑定一个A标签的点击事件,在把上面的代码写到点击事件里面,那么就可以实现刷新了。
第二种:
通过replace()方法也可以实现网页刷新,只不过代码可能会多一些,具体:
<!DOCTYPE html>
<html>
<head>
<meta charset=\"utf-8\">
<title>探乎站长论坛</title>
<script>
function replaceDoc()
{
window.location.replace(\"https://www.8hi.com.cn\")
}
</script>
</head>
<body>
<input type=\"button\" value=\"载入新文档替换当前页面\" onclick=\"replaceDoc()\">
</body>
</html>第三种:
第三种方法直接可以通过HTML标签实现,根本不需要JS,而且还支持自动刷新:
<meta http-equiv=\"refresh\" content=\"5\">
输入上面这段代码到网页后,页面就会自动5秒刷新。
Demand feedback