Javascript - display referrer

Discussion in 'Javascript' started by Trev, Oct 17, 2006.

  1. Trev

    Trev Guest

    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
     
    Trev, Oct 17, 2006
    #1
    1. Advertising

  2. Trev

    Randy Webb Guest

    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:


    <snip>

    > <script>
    > <!--


    <script type="text/javascript">

    Drop the antiquated potentially-harmful comments.

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


    <snip>

    > 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.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 17, 2006
    #2
    1. Advertising

  3. Trev

    Trev Guest

    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.
     
    Trev, Oct 17, 2006
    #3
  4. Trev

    Randy Webb Guest

    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.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 17, 2006
    #4
  5. Trev

    Trev Guest

    Ah, great thanks.

    I've sent you an email (my friend prefers not to have his webpage URL
    released publicly at the moment)
     
    Trev, Oct 17, 2006
    #5
  6. Trev

    Trev Guest

    Trev, Oct 18, 2006
    #6
  7. Trev

    Randy Webb Guest

    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.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 18, 2006
    #7
  8. Trev

    Randy Webb Guest

    Trev said the following on 10/18/2006 5:49 AM:
    > Theres an example of some tracker code in the html source that doesn't
    > trigger the blocked warning here:
    >
    > http://www.nigeria.com/About_Us/Privacy/privacy.html
    > http://www.cs.ucl.ac.uk/staff/M.Oliveira/
    >
    > - look for the bit that has "extreme-dm"


    That is because it's an Internet page and I don't have IE set to warn
    me, so, no warning message.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 18, 2006
    #8
  9. Trev

    Trev Guest

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

    With best wishes

    Trev
     
    Trev, Oct 21, 2006
    #9
  10. Trev

    Randy Webb Guest

    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.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Oct 21, 2006
    #10
  11. Trev

    Trev Guest

    Randy Webb wrote:
    > 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.



    Thanks, mate.

    Trev
     
    Trev, Oct 26, 2006
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harley

    Get referrer URL

    Harley, Jul 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,042
    Harley
    Jul 24, 2003
  2. Harley

    Re: Get referrer URL

    Harley, Jul 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,315
    Harley
    Jul 26, 2003
  3. Aaron

    html referrer spoofing

    Aaron, Jan 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    6,062
    Chris Jackson
    Jan 26, 2004
  4. NWx
    Replies:
    3
    Views:
    23,561
  5. Rod Hilton

    Referrer Spoofing in Javascript?

    Rod Hilton, Oct 8, 2004, in forum: Javascript
    Replies:
    11
    Views:
    245
    John Bokma
    Oct 10, 2004
Loading...

Share This Page