JavaScript to open a simple example of the link page, javascript Link

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.