473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

simple regular expression problem with document.referrer

I have to determine the document.referrer 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.referrer.

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

inside redirect.js subroutine:
function checksource() {
if(document.referrer !~ /(equifax|transunion|experian)/) {
alert("\n\nThis function may only be accessed from a member
angency.\n\nPlease 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!
Jul 23 '05 #1
2 2340
Goober wrote:
I have to determine the document.referrer 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.referrer.

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

inside redirect.js subroutine:
function checksource() {
if(document.referrer !~ /(equifax|transunion|experian)/) {
if (!/(equifax|transunion|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...

[...]
I have researched this and it seems identical to some examples I have seen.
What am I missing?
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?
Is there a better way to do this?
Most probably, but the real issue is your expectation that
document.referrer is reliable - it absolutely isn't. It is very
easily spoofed and can't be relied up at all.
Thanks for your help!


I hope I did.
--
Rob
Jul 23 '05 #2

"RobG" <rg***@iinet.net.auau> wrote in message
news:Za****************@news.optus.net.au...
Goober wrote:
I have to determine the document.referrer 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.referrer.

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

inside redirect.js subroutine:
function checksource() {
if(document.referrer !~ /(equifax|transunion|experian)/) {


if (!/(equifax|transunion|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...

[...]

I have researched this and it seems identical to some examples I have
seen.
What am I missing?


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?
Is there a better way to do this?


Most probably, but the real issue is your expectation that
document.referrer is reliable - it absolutely isn't. It is very
easily spoofed and can't be relied up at all.
Thanks for your help!


I hope I did.
--
Rob

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
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kuok benny | last post by:
Hi, I am trying to use the document.referrer to get the referrer of my home page. Occationally, I get the value of 'blockedReferrer'. Actually how this happen, how the client blocked the...
9
by: Frances Del Rio | last post by:
if I put alert(document.referrer) in code of a file that was linked from another it returns blank... pls, need to get document.referrer, don't why it's not working... read up on oreilly, don't...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
8
by: Rajeev Soni | last post by:
Hi I am looking for the regular expression for validating the allowed file types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the expression should not be case sensitive like...
2
by: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
5
by: Nospam | last post by:
does anyone know if there is anything wrong with this code? <SCRIPT LANGUAGE="JavaScript">document.referrer.indexOf("http://www.example.com") != -1){ ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.