7

I observed it closely by debugging in IE that; IE did set document.referrer if I submit form or click any link but when I redirect to another page using javascript window.location, IE did not set document.referrer.

Muhammad Imran Tariq
  • 22,654
  • 47
  • 125
  • 190
  • 2
    maybe you should specify which version of internet explorer you were using in your tests. and just to say it (it will be in every good answer), it's never safe to depend on a referrer because they are very easily spoofed or disabled. You should therefore think about using a different mechanism. I think this [question](http://stackoverflow.com/questions/402065/internet-explorer-http-referer-issue) is related to yours. – s1lence Dec 03 '12 at 10:22
  • No matter what version you are using you cannot get reffer like imran said. try to get on window.open in some page and check it yourself – polin Dec 03 '12 at 10:39
  • Possible duplicate of [IE has empty document.referrer after a location.replace](http://stackoverflow.com/questions/1890532/ie-has-empty-document-referrer-after-a-location-replace) – My Stack Overfloweth Jun 15 '16 at 19:29

5 Answers5

7

INFO: Internet Explorer Does Not Send Referer Header in Unsecured Situations

When linking from one document to another in Internet Explorer 4.0 and later, the Referer header will not be sent when the link is from an HTTPS page to a non-HTTPS page. The Referer header also will not be sent when the link is from a non-HTTP(S) protocol, such as file://, to another page.

Microsoft

Anjith K P
  • 2,158
  • 27
  • 35
6

Try this

<script type="text/javascript" >            
function redirect(url) {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
        var referLink = document.createElement('a');
        referLink.href = url;
        document.body.appendChild(referLink);
        referLink.click();
    } else {
        location.href = url;
    }
}
</script>

source

Community
  • 1
  • 1
Jonathan de M.
  • 9,721
  • 8
  • 47
  • 72
  • @billy have you found why it hasn't worked and have you found the solution for your case? I don't have same problem (I hope, haven't tested yet), just curious – llamerr Aug 03 '16 at 11:45
  • Nope. I think @Anjith answers that – billy Aug 03 '16 at 15:28
1

IE doesn't Support referrer while you try to send it in pop-up or use window.location.You can send your referrer in many ways. But you will not have it if you try to get it in server side if while change location through a JS popup or change location in JS while using IE, for IE built-in security issue. Check window or window.open property.you can go here

polin
  • 2,745
  • 2
  • 15
  • 20
1

The easiest solution is you can use window.opener.location.href, it works fine in all browsers.

-1

Try this:

<script type="text/javascript">
$("#button").click(function(){

        window.open("about:blank", "win_name", "height=370,width=365, top=50, left=90, scrollbars=yes,resizable=no,menubar=no");
        sForm = '<form action="url.php" method="post" target="win_name">';
        sForm += '</form>';
        //alert(sForm);return;
        $(sForm).appendTo('body').submit();
        return;

     });
</script>
bummi
  • 27,123
  • 14
  • 62
  • 101