js实现页面跳转的几种方式
- 按钮点击
- 链接点击
- 本地连接直接跳转
- 跳转打开一个新窗口
- 弹窗提示跳转页面
- 在input标签中给一个按钮,通过点击按钮跳转,当前页面跳转
1
<input type="button" value="点我" onClick="location.href='https://itsxzjz.github.io/'" />
- history.go()方法
1
<a href="javascript:history.go(x)">返回上x步</a>
- 本地跳转,window上的原生方法
1
2
3<script>
location.href='https://itsxzjz.github.io/';
</script> - 打开新的一个窗口
1
<a href="javascript:" onClick="open('https://itsxzjz.github.io/')"</a>
- javascript内,window身上的一个方法navigate()
1
2
3<script language="javascript">
navigate("https://itsxzjz.github.io/");
</script> - 弹窗提示跳转
1
2
3
4
5
6<script>
function logout()...{
alert("你确定要跳转吗?");
location.href="https://itsxzjz.github.io/"
}
</script>如果对你有所帮助,欢迎点赞收藏哦,共同进步哦!!
你会了吗?谢谢你请我喝奶茶,盒盒盒~ ↓↓↓
- 本文作者: it JinZhan
- 本文链接: http://example.com/2021/09/06/2021-9-6-js实现页面跳转的几种方式/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!