js page jump

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)

  1. <script language="javascript" type="text/javascript">
  2. window.location.href="b.html";
  3. </script>

The second type: (return to the previous page)

  1. <script language="javascript">
  2. window.history.go(-1);
  3. </script>

The third type:

  1. <script language="javascript">
  2. window.navigate("b.html");
  3. </script>

The fourth type:

  1. <script language="javascript">
  2. top.location=’b.html’;
  3. </script>

Guess you like

Origin blog.csdn.net/m0_59735348/article/details/119521301