simple regular expression problem with document.referrer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Goober

    #1

    simple regular expression problem with document.referrer

    I have to determine the document.referr er of the individual coming to my
    site. I want to send everyone not coming from one of those sites to an
    alternate location (The names below are just used as examples).
    I want to match on one of those names anywhere in the document.referr er.

    In the main program I call a subroutine like this:
    <script LANGUAGE="javas cript" SRC="../js/redirect.js"></script>
    <body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0 "
    onload="checkso urce()">

    inside redirect.js subroutine:
    function checksource() {
    if(document.ref errer !~ /(equifax|transu nion|experian)/) {
    alert("\n\nThis function may only be accessed from a member
    angency.\n\nPle ase click OK to be redirected to the appropriate page.\n\n");
    location.href = "http://999.999.999.999/bad_source.asp" ;
    }
    }

    However, everytime this code is executed, it generates a runtime
    error:error:
    line:2
    Error:Expected ')'


    I have researched this and it seems identical to some examples I have seen.
    What am I missing?
    Is there a better way to do this?
    Thanks for your help!


  • RobG

    #2
    Re: simple regular expression problem with document.referr er

    Goober wrote:[color=blue]
    > I have to determine the document.referr er of the individual coming to my
    > site. I want to send everyone not coming from one of those sites to an
    > alternate location (The names below are just used as examples).
    > I want to match on one of those names anywhere in the document.referr er.
    >
    > In the main program I call a subroutine like this:
    > <script LANGUAGE="javas cript" SRC="../js/redirect.js"></script>
    > <body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0 "
    > onload="checkso urce()">
    >
    > inside redirect.js subroutine:
    > function checksource() {
    > if(document.ref errer !~ /(equifax|transu nion|experian)/) {[/color]

    if (!/(equifax|transu nion|experian)/.test(document. referrer)) {

    will do the trick, however I suspect you have a much larger range of
    values to check and there are other issues with what you are trying
    to do...

    [...][color=blue]
    >
    > I have researched this and it seems identical to some examples I have seen.
    > What am I missing?[/color]

    This is a server-side issue but you appear to be using what is
    primarily a client-side technology. Are you sure you're there isn't
    something better?
    [color=blue]
    > Is there a better way to do this?[/color]

    Most probably, but the real issue is your expectation that
    document.referr er is reliable - it absolutely isn't. It is very
    easily spoofed and can't be relied up at all.
    [color=blue]
    > Thanks for your help![/color]

    I hope I did.


    --
    Rob

    Comment

    • Goober

      #3
      Re: simple regular expression problem with document.referr er


      "RobG" <rgqld@iinet.ne t.auau> wrote in message
      news:Za%2e.663$ Zn.35037@news.o ptus.net.au...[color=blue]
      > Goober wrote:[color=green]
      >> I have to determine the document.referr er of the individual coming to my
      >> site. I want to send everyone not coming from one of those sites to an
      >> alternate location (The names below are just used as examples).
      >> I want to match on one of those names anywhere in the document.referr er.
      >>
      >> In the main program I call a subroutine like this:
      >> <script LANGUAGE="javas cript" SRC="../js/redirect.js"></script>
      >> <body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0 "
      >> onload="checkso urce()">
      >>
      >> inside redirect.js subroutine:
      >> function checksource() {
      >> if(document.ref errer !~ /(equifax|transu nion|experian)/) {[/color]
      >
      > if (!/(equifax|transu nion|experian)/.test(document. referrer)) {
      >
      > will do the trick, however I suspect you have a much larger range of
      > values to check and there are other issues with what you are trying
      > to do...
      >
      > [...][color=green]
      >>
      >> I have researched this and it seems identical to some examples I have
      >> seen.
      >> What am I missing?[/color]
      >
      > This is a server-side issue but you appear to be using what is
      > primarily a client-side technology. Are you sure you're there isn't
      > something better?
      >[color=green]
      >> Is there a better way to do this?[/color]
      >
      > Most probably, but the real issue is your expectation that
      > document.referr er is reliable - it absolutely isn't. It is very
      > easily spoofed and can't be relied up at all.
      >[color=green]
      >> Thanks for your help![/color]
      >
      > I hope I did.
      >
      >
      > --
      > Rob[/color]
      You did help. Thank you much.
      By the way, this is not meant as high security. Just a marketing thing where
      they want to control flow. If security was a concern, I would explore
      something different.
      Again,Thanks


      Comment

      Working...