Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having issues trying to use the referrer property

Status
Not open for further replies.

chrisennis

Programmer
Joined
Jul 25, 2006
Messages
2
Location
US
Please accept my apologies, but I am new to Javascript.

I have a page where I need to redirect anyone who does not come from a specific set of pages. It was working until I started adding multiple pages and using the 'or' statement. Can anyone tell me what is wrong with the syntax here?

[code<script language="javascript">
if (document.referrer != " || document.referrer !=" || document.referrer !=" || document.referrer !=" || document.referrer !=" location.href = "</script> [/code]

Thanks in advance for any help,
-Chris
 
i think you want &&, not ||...


Code:
<script language="javascript">
    if   (document.referrer != "[URL unfurl="true"]http://www.dmaleads.com/argent/index.html"[/URL]
    && document.referrer !="[URL unfurl="true"]http://www.dmaleads.com/argent/home.html"[/URL]
    && document.referrer !="[URL unfurl="true"]http://www.dmaleads.com/argent/faqs.html"[/URL]
    && document.referrer !="[URL unfurl="true"]http://www.dmaleads.com/argent/mortgage_leads101.html"[/URL]
    && document.referrer !="[URL unfurl="true"]http://www.dmaleads.com/argent/pricing_quantity.html")[/URL]
    location.href = "[URL unfurl="true"]http://www.dmaleads.com/argent/index.html";[/URL]
</script>

right? bring us to index.html if we are NOT coming from any of the listed pages?



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Isn't that the 'and' operator? Seems like that would redirect me if they didn't come from all of the sites (which probably won't happen).

At this point, using either && or || results in the user being redirected to index.html everytime (no matter where the came from).
 
what are you going for? if you want to redirect a user if they came from any page OTHER THAN index, home, faqs, mortgage_leads101 or pricing_quantity, then you'll need the AND statement. think about it:

Code:
if a user did not come from index and
   a user did not come from home and
   a user did not come from faqs and
   a user did not come from mortgage leads and
   a user did not come from pricing
then
   bring him to the home page
end



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top