我想一次刷新我的页面 5 次
i want to refresh my page 5 times on one click
我怎样才能一次点击刷新我的页面 5 次这里是我的代码
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button type="button" onClick="Refresh()">Close</button>
<script>
function Refresh() {
for (var i=0; var i<5; var i++) {
window.parent.location = window.parent.location.href;
}
}
您可以添加查询字符串参数 refreshesLeft
,然后点击按钮重定向到 mypage?refreshesLeft=5
。添加 onLoad 处理程序以检查您是否设置了查询字符串参数,如果是,则将其递减并重定向。
<button type="button" onClick="Refresh()">Close</button>
<script>
function Refresh(refreshesLeft) {
refreshesLeft = refreshesLeft || 5;
window.parent.location = window.parent.location.href + '?refreshesLeft='+refreshesLeft;
}
function onLoad() {
let params = new URLSearchParams(document.location.search.substring(1));
let rl = params.get("refreshesLeft")
if (rl) Refresh( (rl | 0 ) -1)
}
document.addEventListener("DOMContentLoaded", onLoad)
</script>
我怎样才能一次点击刷新我的页面 5 次这里是我的代码
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button type="button" onClick="Refresh()">Close</button>
<script>
function Refresh() {
for (var i=0; var i<5; var i++) {
window.parent.location = window.parent.location.href;
}
}
您可以添加查询字符串参数 refreshesLeft
,然后点击按钮重定向到 mypage?refreshesLeft=5
。添加 onLoad 处理程序以检查您是否设置了查询字符串参数,如果是,则将其递减并重定向。
<button type="button" onClick="Refresh()">Close</button>
<script>
function Refresh(refreshesLeft) {
refreshesLeft = refreshesLeft || 5;
window.parent.location = window.parent.location.href + '?refreshesLeft='+refreshesLeft;
}
function onLoad() {
let params = new URLSearchParams(document.location.search.substring(1));
let rl = params.get("refreshesLeft")
if (rl) Refresh( (rl | 0 ) -1)
}
document.addEventListener("DOMContentLoaded", onLoad)
</script>