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.