The following are four ways to achieve page jump in JS:
-
window.location.href= 'url': The more commonly used method, directly follow the specified place to jump.
-
window.history.back(-1): Refers to the browser returning to the last visited page until the originally visited page was visited.
-
window.navigate("url"): The navigate object contains information about the browser, and can also be used as a page jump, and the place to be jumped is directly added later.
-
top.location= 'url': When there is an inline frame in the page, specify the topmost window to jump to, and the outermost browser containing the frame.
Example:
To achieve jumping from one page A to another page B, the js implementation is to add the jump code to the js code of A.
The first type: (jump to b.html)
- <script language="javascript" type="text/javascript">
- window.location.href="b.html";
- </script>
The second type: (return to the previous page)
- <script language="javascript">
- window.history.go(-1);
- </script>
The third type:
- <script language="javascript">
- window.navigate("b.html");
- </script>
The fourth type:
- <script language="javascript">
- top.location=’b.html’;
- </script>