Javascript - display referrer

T

Trev

Hi all,
I'm trying to create some javascript that will provide the user of the
referring page, but if I do something like the following:

<HTML>
<HEAD>
</HEAD>
<BODY>

<script>
<!--
url= document.referrer;

document.write('<A HREF="' + url + '">This Link</A>');
//-->
</script>

</BODY>

</HTML>

this brings out a drop-down window on IE 6 (using WInXP SP2) saying
"active content is blocked" etc. However, similar useage of the same
document.referrer function in another page I have seen is OK. What is
wrong? The behaviour is the same if the <script> tag contains
"JavaScript", or not.

Also, if I have a link to the page containing the code above on a
webpage (say "C:\Trev\refer1.htm"),
then the referrer is given as "C:\Trev", and not the actual webpage
referrer. Why?

TIA

Trev
 
R

Randy Webb

Trev said the following on 10/17/2006 5:49 AM:
Hi all,
I'm trying to create some javascript that will provide the user of the
referring page, but if I do something like the following:

<script>
<!--

<script type="text/javascript">

Drop the antiquated potentially-harmful comments.
url= document.referrer;

document.write('<A HREF="' + url + '">This Link</A>');

this brings out a drop-down window on IE 6 (using WInXP SP2) saying
"active content is blocked" etc. However, similar useage of the same
document.referrer function in another page I have seen is OK. What is
wrong? The behaviour is the same if the <script> tag contains
"JavaScript", or not.

It is because you are testing locally. Either set IE to allow Active
Content in the PC Zone or use the Mark Of The Web.
Also, if I have a link to the page containing the code above on a
webpage (say "C:\Trev\refer1.htm"),
then the referrer is given as "C:\Trev", and not the actual webpage
referrer. Why?

Because document.referrer doesn't work properly in IE when opening a
local page. Test it from a server.
 
T

Trev

Thanks.

Is there any way to stop the "Active content blocked window" on
computers over whom I have no control? Its just that I've seen two
implementations of the referrer code; one produces the drop-down
windown and one doesn't.
 
R

Randy Webb

Trev said the following on 10/17/2006 6:47 AM:
Thanks.

Is there any way to stop the "Active content blocked window" on
computers over whom I have no control?

Think about what you are asking there. Basically you are asking "Can I
control the settings on a computer that I have no control over?" And the
answer is, obviously, no. If people are seeing that message from a
website, then the PC is set to give that security warning. If they are
seeing it from a local file, then search the archives for "Mark of the Web".

Its just that I've seen two implementations of the referrer code;
one produces the drop-down windown and one doesn't.

Whats the code that doesn't produce the drop-down?
P.S. It isn't the use of document.referrer that causes that menu, it is
any script element in the page (even an empty script block). Test it:

<script type="text/javascript">
</script>

Open it in an IE that is set to notify, and you will get that warning
from the above block, even though there is no code in it.
 
T

Trev

Ah, great thanks.

I've sent you an email (my friend prefers not to have his webpage URL
released publicly at the moment)
 
R

Randy Webb

Trev said the following on 10/17/2006 7:51 AM:
Ah, great thanks.

I've sent you an email (my friend prefers not to have his webpage URL
released publicly at the moment)

This email address doesn't receive Internet mail (It only receives AOL
mail) so you tried to email me but it got bounced back to you :)

Search the archives over the last few days and find One Dumm Hikk and
the email address it uses and you can email it to me there.
 
T

Trev

Hi Randy,
I've sent you an email to your other address - hopefully you got it OK
;)

With best wishes

Trev
 
R

Randy Webb

Trev said the following on 10/21/2006 3:45 PM:
Hi Randy,
I've sent you an email to your other address - hopefully you got it OK
;)

Yes, I got it. And that security warning is dictated by user settings
and the script in the page. If IE is set to give ActiveX warnings and
not Script warnings, then you only get it with an ActiveX. There is
nothing the programmer can do to avoid it other than not using it.
 
T

Trev

Randy said:
Trev said the following on 10/21/2006 3:45 PM:

Yes, I got it. And that security warning is dictated by user settings
and the script in the page. If IE is set to give ActiveX warnings and
not Script warnings, then you only get it with an ActiveX. There is
nothing the programmer can do to avoid it other than not using it.


Thanks, mate.

Trev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top