SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 1999
    Location
    Highlands Ranch, CO
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Syntax question...

    2 Questions:

    1. I am trying to have my script determine if the referer of the page was from a certain directory - so the document.referer can be anything in the "times" directory, and if it isn't then you are redirected. Here is an example:

    <script language="JavaScript">
    <!--
    var page;
    var ref;

    page = "/members/times/times.asp";
    ref = document.referrer;
    if (ref != * + "/times/" + *)
    {
    location.href = page;
    }
    //-->
    </script>

    The asterix is not working for a designation of 'anything'. What is the proper syntax for this?

    2. Is there a good tutorial around on how to disect a string using Javascript? I am looking to see if the refering url contains a certain string.

    TIA!

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's what indexOf("string") is for:
    if (ref.indexOf("/times") == -1){
    // /times wasn't in the referrer url
    }

    Thau's javascript tutorials at webmonkey.com are both good solid js overviews.
    ck :: bringing chris to the masses.

  3. #3
    SitePoint Zealot
    Join Date
    Dec 1999
    Location
    Highlands Ranch, CO
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great Anarchos! Thanks, you really pointed me in the right direction!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •