In addition to the usual way of linking in the page, there are many ways to use javascript. Here are some ways to open links using javascript:
1. Use the open method of window to open the link. Here you can open the link in the formulation page, or you can customize the size of the opening page, etc.
<a href=”javascript:window.open('http://www.google.com','_self') "> open a link 1</a><br/>2. Use the document.URL property to type a new page. Not enough This method doesn't seem to work in firefox.
<a href=”javascript:document.URL = 'http://www.google.com' "> open a link 2</a><br/>
3. Use the location property href to open the link.
<a href=”javascript:window.location.href='http://www.google.com'"> open a link 3 </a><br/>
4. Use the location method assign to open the link. This effect is the same as the previous method.
<a href="javascript:window.location.assign('http://www.google.com')"> open a link 4</a><br/>5. Use the location method replace to open the link, which is slightly different from the previous assign method. The difference is that the URL of the page that was replaced when using replace will not enter the history object, which means that it cannot return to the replaced page by backing.
<a href="javascript:window.location.replace('http://www.google.com')"> open a link 5</a><br/>6. Normal links, of course, this is the most friendly way to search engines, and you can also use a window to open a specified link. Only in this way can the linked page be crawled by the search engine spider.
<a href="http://www.google.com"> open a link 5</a><br/>
The above is a summary of the JavaScript implementation method to open the link page introduced by the editor. I hope it will be helpful to everyone!