JavaScript to open a simple example of the link page, javascript Link
In addition to the common method of link on the page, if javascript is used, there are many other methods. Below are some methods of using javascript to open the link:
1. Use the window open method to open the link. Here, you can open the link on the page, or customize the size of the opened page.
<a href=”javascript:window.open(‘http://www.bkjia.com','_self') “> open a link 1</a><br/>
2. Use the document. URL attribute to call a new page. This method does not seem to work in firefox.
<a href=”javascript:document.URL = ‘http://www.bkjia.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.bkjia.com'”> open a link 3 </a><br/>
4. Use the location method assign to open the link. The effect is the same as that in the previous method.
<a href=”javascript:window.location.assign(‘http://www.bkjia.com')”> open a link 4</a><br/>
5. using the location method replace to open the link is slightly different from the previous assign Method. The difference is that the URL of the replaced page will not enter the history object when replace is used, that is to say, you cannot return to the replaced page in the form of backend.
<a href=”javascript:window.location.replace(‘http://www.bkjia.com')”> open a link 5</a><br/>
6. Normal links. Of course, this is the most friendly method for search engines. You can also specify a window for opening a link. Only in this way can the linked page be crawled by the search engine's spider.
<a href=”http://www.bkjia.com”> open a link 5</a><br/>
The simple example of the above JavaScript code to open the link page is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the help house.