FIX: document.referrer Property Returns Incorrect Value
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>
Additional query words:
Keywords : kbprg vbObjMdlIE
Version : WINDOWS:3.0,3.01
Platform : WINDOWS
Issue type : kbbug