方式
| 序号 | 方法 |
|---|---|
| 1 | history.go() |
| 2 | location.reload() |
| 3 | location = location |
| 4 | location.assign(location.href) |
| 5 | location.replace(location.href) |
| 6 | location.replace(document.referrer) |
| 7 | window.location.href = document.URL |
| 8 | window.location.href = document.location.href |
| 9 | window.open(document.referrer, “_parent”, “”) |
| 10 | document.location.href = window.location.href |
| 11 | document.location.href = document.URL |
| 12 | document.execCommand(“Refresh”) (已废弃) |
| 13 | window.navigate(url)(只针对IE浏览器,避免使用,不兼容) |
参考文档
1、https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand
2、https://blog.youkuaiyun.com/m0_46652188/article/details/119867048
3、https://blog.youkuaiyun.com/hu1010037197/article/details/100427393
其他

本文列举了多种在Web开发中用于刷新页面或改变页面URL的方法,包括history.go(),location.reload(),location赋值等方式,并提到了部分已废弃或浏览器不兼容的命令,如document.execCommand(Refresh)和window.navigate()。
1552

被折叠的 条评论
为什么被折叠?



