h5实现页面跳转页面
使用 window.location.href 实现跳转
通过修改 window.location.href 属性可以直接跳转到目标 URL。
window.location.href = 'https://example.com/target.html';
使用 location.replace 实现跳转(无历史记录)
location.replace 会替换当前页面,且不会在浏览器历史记录中生成新条目。

location.replace('https://example.com/target.html');
使用 location.assign 实现跳转(保留历史记录)
与 href 类似,但更明确地表示跳转行为。
location.assign('https://example.com/target.html');
使用 <a> 标签跳转
通过 HTML 的 <a> 标签实现跳转,适合静态页面或需要 SEO 的场景。

<a href="target.html">跳转到目标页面</a>
使用 history.pushState 实现无刷新跳转
适用于单页应用(SPA),仅更新 URL 而不刷新页面,需配合路由库使用。
history.pushState({}, '', 'target.html');
使用 meta 标签自动跳转
通过 <meta> 标签的 http-equiv 属性实现自动跳转,常用于重定向。
<meta http-equiv="refresh" content="5;url=target.html">
注意事项
- 相对路径需确保与当前页面的目录关系正确。
- 跨域跳转需遵循浏览器安全策略。
- SPA 中推荐使用路由库(如 Vue Router、React Router)管理跳转逻辑。






