Home >Web Front-end >JS Tutorial >How to control page jump with javascript
Method: 1. Use "window.location.href="page address""; 2. Use the "window.history.back()" statement; 3. Use the "window.navigate()" statement; 4. Use the "self.location="address"" statement.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
The first one: jump directly and add parameters
<script language="javascript" type="text/javascript"> window.location.href="login.jsp?backurl="+window.location.href; </script>
directly Jump without parameters:
<script>window.location.href='http://www.baidu.com';</script>
Second: Return to the last preview interface
<script language="javascript"> alert("返回"); window.history.back(-1); </script>
Tag nesting:
<a href="javascript:history.go(-1)">返回上一步</a> <a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
Third Type: The specified jump page is invalid for the frame. . .
<script language="javascript"> window.navigate("top.jsp"); </script>
The fourth way: specifying the own jump page is invalid for the frame. .
<script language="JavaScript"> self.location='top.htm'; </script>
Application examples:
<head> <script language="javascript"> function old_page() { window.location = "login.aspx" } function replace() { window.location.replace("login.aspx") } function new_page() { window.open("login.aspx") } </script> </head> <body> <input type="button" onclick="new_page()" value="在新窗口打开s"/> <input type="button" onclick="old_page()" value="跳转后有后退功能"/> <input type="button" onclick="replace()" value="跳转后没有后退功能"/> </body>
For more programming-related knowledge, please visit: Programming Video! !
The above is the detailed content of How to control page jump with javascript. For more information, please follow other related articles on the PHP Chinese website!