FIX: document.referrer Property Returns Incorrect Value |
Q164496
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.
This has been confirmed to be a problem with the object model of Internet Explorer.
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>
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.
===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 : kbprogramming
Issue type : kbbug
Technology : kbIEsearch kbAudDeveloper kbSDKIESearch kbSDKIE300 kbSDKIE301
|
Last Reviewed: August 29, 1999 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |