Normally, the referrer is traceable through:
document.referrer
$_SERVER[\'HTTP_REFER
What you're asking for cannot be done in Firefox.
The current context menu implementation always passes the current document as a referrer:
// Open linked-to URL in a new window.
openLink: function () {
var doc = this.target.ownerDocument;
urlSecurityCheck(this.linkURL, doc.nodePrincipal);
openLinkIn(this.linkURL, "window", {
charset: doc.characterSet,
referrerURI: doc.documentURIObject // <----------------
});
},
// Open linked-to URL in a new tab.
openLinkInTab: function () {
var doc = this.target.ownerDocument;
urlSecurityCheck(this.linkURL, doc.nodePrincipal);
openLinkIn(this.linkURL, "tab", {
charset: doc.characterSet,
referrerURI: doc.documentURIObject // <----------------
});
},
// open URL in current tab
openLinkInCurrent: function () {
var doc = this.target.ownerDocument;
urlSecurityCheck(this.linkURL, doc.nodePrincipal);
openLinkIn(this.linkURL, "current", {
charset: doc.characterSet,
referrerURI: doc.documentURIObject // <----------------
});
},
Obviously, userscripts are not allowed to change the context menu implementation, so the only way out is a browser extension.
(Or, which would be a pretty poor hack, disable the context menu by calling preventDefault()
on the contextmenu
event, and use your own custom context menu)