Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: open

Message Too Old, No Replies

once upon a time in a browser

refferer puzzle

     
7:05 am on Jan 14, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 16, 2004
posts:61
votes: 0


why does this work in Firefox but not in IE?

<script language="JavaScript" type="text/javascript">
<!--

if (document.referrer == "http://mysite.com/group.html")
document.write('You came from group');

//-->
</script>

2:52 pm on Jan 14, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


Some things don't work quite right in browsers when working within file system (ie file: protocol). It took me a while to find this out for the onerror event for images in Moz.

If you have a local webserver, try getting the document.referrer property, and it will magically appear.

5:43 pm on Jan 14, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 16, 2004
posts:61
votes: 0


...and by that you mean?
8:00 pm on Jan 14, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


Put the script inside a page being served from a webserver and it will work in IE too.
2:56 am on Jan 15, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 16, 2004
posts:61
votes: 0


thanks

I've decided to go with php, at least one thing that actually works in this world lol

9:43 pm on Jan 16, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
posts:3416
votes: 0


Don't forget that the referrer string can not be trusted. A user can alter what, if any, data they send as the referrer.