Comparison of href and replace in javascript (detailed description)

Source: Internet
Author: User
The following section describes how to compare href and replace in javascript ). I think this is quite good. Now I will share it with you and give you a reference. Let's take a look at the small Editor. When using javascript, sometimes you are too familiar with frequently used methods and ignore the nuances of their principles.

Example:

Window. location. href, window. location. replace.

Both methods allow the page to jump to a new page, but I ignore the details after the jump, such as the original page returned.

Window. location. the href in href is actually the href In the tag. After you use this to jump to the page, you can use the browser's back button to return to the original page, or you can use history. go (-1) function jumps to the original page.

The window. location. replace (url) method allows the browser to clear the historical URLs and reset the url settings. When the browser's back button or forward button is used, it will not jump to the original page, but to the previous page.

That is, the replace () method does not generate a new record in the History object. When this method is used, the new URL overwrites the current record in the History object.

The comparison of href and replace in the above javascript section (detailed description) is all the content shared by the editor. I hope to give you a reference and support for PHP.

For more information about the comparison of href and replace in javascript (detailed description), please follow the PHP Chinese website!

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.