Home >Web Front-end >JS Tutorial >How to jump from one page to a new page in js?
This article mainly introduces you to the related issues of how to implement js page jump to a new page. In fact, js jumps are generally used in advertising jumps and link effects. So we need to first understand what the essential concept of js page jump is, that is, the change of browser object window location (url).
Then the following is a summary of several js methods to jump to a specified page.
1. Jump directly in the original form
<script type="text/javascript"> window.location.href="你所要跳转的页面"; </script>
2.Open a new page in a new window
<script type="text/javascript"> window.open('你所要跳转的页面'); </script>
3. Jump to the specified page
<script language="javascript" type="text/javascript"> window.location.href="login.jsp?backurl="+window.location.href; </script>
4. Jump to the specified demo.html page
<script language="JavaScript"> self.location=’demo.html’; </script>
5 .Add judgment jump
<script language="javascript"> alert("非法访问!"); top.location='xx.jsp'; </script>
6.Button button to jump to the page
<button onclick="window.location.href='xxx.html'">点击跳转</button>
The above is a summary of the relevant methods of how to jump the page in js, which has certain Reference value, I hope it will be helpful to friends in need.
Note: The Location object is stored in the Location property of the Window object and represents the Web address of the document currently displayed in that window. Its href attribute stores the completeness of the document URL, and other attributes describe various parts of the URL respectively. These properties are very similar to the URL properties of the Anchor object (or Area object). when a The Location object is converted to a string and the value of the href attribute is returned. This means you can use the expression location instead of location.href.
The above is the detailed content of How to jump from one page to a new page in js?. For more information, please follow other related articles on the PHP Chinese website!