I have developed a Add-on for Firefox.
It has a redirect link:
https://www.google.com.vn/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB0QFjAA&url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2FAdd-ons%2FCode_snippets%2FTabbed_browser&ei=3pfhU-TMIMPo8AXhg4GoAw&usg=AFQjCNGYBJDxF8FAEl3gxl1DcqTes93HFQ&bvm=bv.72197243,d.dGc
This link redirects to:
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser
I am using this code to get redirect link before redirect
var doc = event.originalTarget;
var origEl = event.target || event.srcElement;
if(origEl.tagName === 'A' || origEl.tagName === 'a') {
alert( gBrowser.currentURI.spec);
}
It gives:
https:// developer. mozilla. org/en-US/Add-ons/Code_snippets/Tabbed_browser
But I need the previous redirect link.
I think gBrowser.currentURI.spec get current Url of tab. I searched on Google but didn't find method to get original redirect link.
gBrowser.webNavigation.referringURI
This will give you the current tab only. If you want of a specific tab then go:
var tabIndex = 0; //first tab
var referredFromURI = gBrowser.tabContainer.childNodes[tabIndex].linkedBrowser.webNavigation.referringURI;
This isn't really the redirected from, but the referred from. But it works. If there is no referred URI than this property is null.
Also the person who downvoted your question is a loser. Good question you asked.
来源:https://stackoverflow.com/questions/25152404/what-is-method-to-get-url-before-tab-redirect-in-firefox