Use document. referrer to determine whether the page is a link adjustment, a new one, or a new source.

Source: Internet
Author: User

Use document. referrer to determine whether the page is a link adjustment, a new one, or a new source.

Business Requirements:

1. Copy the link or a new link in the QQ browser and click "back" to go to the List page;

2. The store "return" adjusted from the list Page Link executes the "return" action of the browser. The advantage is that it can be directly located at the last browsing position on the list page.

Function ClickBack () {if (document. referrer = "" | document. referrer. indexOf ("cases") =-1) {// return to the case list window. location. href = '/cases/';} else {history. back ();}}


If the value of document. referrer on the newly opened page is "",


Compatibility test:



Operation IE6 IE7 IE8 IE9 Firefox Chrome Opera Safari
Enter the URL directly in the address bar "" "" "" "" "" "" "" ""
Access URL from bookmarks "" "" "" "" "" "" "" ""
Click the hyperlink from page a to jump to page B (target = "_ self ")
Click the hyperlink from page a to jump to page B (target = "_ blank ")
Right-click the hyperlink from page A and open page B on the new tab. - ""
Right-click the hyperlink from page A and open page B in A new window ""
Drag to the address bar "" Cannot be dragged Cannot be dragged "" "" "" "" ""
Drag to the tab bar - "" "" "" "" "" "" ""
Use the browser's forward and backward buttons
Modify location. href in JS "" "" ""
JS uses window. open "" "" "" ""
Server redirection (302 redirection) Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages
Page Meta Refresh "" "" "" "" "" Turn page Turn page Turn page

In the above table, "√" indicates that the referrer can be obtained normally. "" indicates that the referrer is empty.

The test result is from the network. The author is not familiar with it. Thank you for sharing it.


Operation IE6 IE7 IE8 IE9 Firefox Chrome Opera Safari
Enter the URL directly in the address bar "" "" "" "" "" "" "" ""
Access URL from bookmarks "" "" "" "" "" "" "" ""
Click the hyperlink from page a to jump to page B (target = "_ self ")
Click the hyperlink from page a to jump to page B (target = "_ blank ")
Right-click the hyperlink from page A and open page B on the new tab. - ""
Right-click the hyperlink from page A and open page B in A new window ""
Drag to the address bar "" Cannot be dragged Cannot be dragged "" "" "" "" ""
Drag to the tab bar - "" "" "" "" "" "" ""
Use the browser's forward and backward buttons
Modify location. href in JS "" "" ""
JS uses window. open "" "" "" ""
Server redirection (302 redirection) Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages Targeting previous pages
Page Meta Refresh "" "" "" "" "" Turn page Turn page Turn page

In the above table, "√" indicates that the referrer can be obtained normally. "" indicates that the referrer is empty.

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.