那么下面就是给大家总结几种js跳转到指定页面的方法。
1.在原来的窗体中直接跳转
<script type="text/javascript">window.location.href="你所要跳转的页面";</script>
2.在新的窗口中打开新页面
<script type="text/javascript">window.open('你所要跳转的页面');</script>
3.跳转指定页面
<script language="javascript" type="text/javascript">window.location.href="login.jsp?backurl="+window.location.href;</script>
4.跳转到指定的demo.html页面
<script language="javascript"> self.location=’demo.html’; </script>
5.加判断跳转
<script language="javascript"> alert("非法访问!"); top.location='xx.jsp'; </script>
6.button按钮跳转页面
<button onclick="window.location.href='xxx.html'">点击跳转</button>
以上就是关于js怎么跳转页面的相关方法总结,具有一定的参考价值,希望对有需要的朋友有所帮助。
注:location 对象存储在 window 对象的 location 属性中,表示那个窗口中当前显示的文档的 web 地址。它的 href 属性存放的是文档的完整 url,其他属性则分别描述了 url 的各个部分。这些属性与 anchor 对象(或 area 对象)的 url 属性非常相似。当一个 location 对象被转换成字符串,href 属性的值被返回。这意味着你可以使用表达式 location 来替代 location.href。
以上就是js怎么实现一个页面跳至新的页面?的详细内容。
