From within a browser extension (BHO) I want to know the URL that referred a user to the current page. I thought I could just get the document.referrer, but I find that's blank if links are opened in a new window. Is this just tough bikkies or can I use opener.location.href in some cases, or something else?
As a follow-up, I'm currently getting this when the page has loaded, ie on DocumentComplete, but I'd prefer to get it on BeforeNavigate2. I don't see any way to do that except use the current location as the referrer on BeforeNavigate2, however that will give me the current page as a referrer if users enter a new URL in the address bar. ie it'll look like they navigated from a link on site A to site B where actually they went to site A then typed in the url for site B.
UPDATE: From what I can tell, sometimes the 'opener' property will be set (if the window has been opened from javascript?) and therefore we can get the effective referrer page from that. Anyone know specifically in which situations this is available?