FIX: document.referrer Property Returns Incorrect Value

Last reviewed: September 30, 1997
Article ID: Q164496
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 3.0, 3.01

SYMPTOMS

The referrer property of the document object should contain the calling page's URL. In Internet Explorer version 3.0 and 3.01, the referrer property contains the current page's URL.

CAUSE

This has been confirmed to be a problem with the object model of Internet Explorer.

RESOLUTION

To work around this problem, you can use script code to pass the information in a cookie.

The following two files, Alpha.htm and Comments.htm illustrate how to work around this problem. Alpha.htm uses a cookie named referrer to keep track of the calling page's URL. It passes this cookie to Comments.htm, which then displays the referrer.

   ====File Alpha.htm====
   <HTML>
   <HEAD>
   <TITLE>New Page</TITLE>
   <SCRIPT LANGAUGE="JAVASCRIPT">
   function clicked() {
     document.cookie='referrer='+ document.location + '; path=/';
     }
   </SCRIPT>
   </HEAD>
   <BODY>

   <a href ="http://Server/Comments.htm" onClick=clicked();>Comments</a>
   <BR>

   </BODY>
   </HTML>

   ====File Comments.htm====
   <HTML>
   <HEAD>
   <TITLE>New Page</TITLE>
   <script langauge="Javascript">
   document.write("<BR><BR>cookie=" + document.cookie );
   </script>
   </HEAD>
   <BODY></BODY>
   </HTML>

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been fixed in Internet Explorer 4.0.

MORE INFORMATION

Steps to Reproduce Behavior

The following two pages illustrate the problem. Page1.htm calls Page2.htm, which displays the referer property.

   ===Page1.htm===
   <HTML>
   <HEAD><TITLE>Page 1</TITLE></HEAD>
   <BODY>
   <a href ="http://Server/Comments.htm" >Comments</a><BR>
   </BODY>
   </HTML>

   ===Page2.htm===
   <HTML>
   <HEAD><TITLE>Page 2</TITLE>
   <script langauge="Javascript">
      document.write(document.referrer);
   </script>
   </HEAD>
   <BODY></BODY>
   </HTML>
Keywords          : vbObjMdlIE kbprg kbbuglist
Technology        : kbInetDev
Version           : 3.0 3.01
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.