Differences between Document. location. href and. replace

Source: Internet
Author: User

Differences between Document. location. href and. replace

Both document. location. href and document. location. replace can be switched from page A to page B. The following describes their differences.

Both document. location. href and document. location. replace can be switched from page A to page B, but their differences are:

After switching with document. location. href, you can return to the original page.

After switching with document. location. replace, you cannot return it back to the original page.

For document. location. href or other failback methods, I also found details,

Here is an example:

Assume there are three pages: a.htm B .htm C.htm.

A.htm has the following sentence: document. location. href = "/B .htm ";

B .htm has the following sentence: document. location. href = "/c.htm ";

Note that both of them can be switched back.

1: when switching from A to B and then to C, the actual memory retains three pages: A, B, and C.

2: when it is rolled back to B, the C page is cleared out of memory!

3: Roll Back again. When page A is reached, page B is also cleared out of memory!

4: When you go forward again (instead of switching, but forward) to page B,

The memory retains A and B.

>>> When a document is replaced by location. replace (), it will be removed from the current historical object

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.