Javascript刷新页面的几种方法:
作用:prompt弹框输完可以继续使用
1 history.go(0)
2 window.location.reload()
window.location.reload(true)
3 location=location
4 location.assign(location)
5 document.execCommand(''Refresh'')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script>
var age = Number(prompt("请问你年龄:"))
if(age < 25 && age > 0) {
alert("年轻")
} else if(age < 100 && age > 25) {
alert("有点大了咯")
} else {
alert("输入错误")
}
location.replace(location)
</script>
<body>
</body>
</html>