Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Referer Redirect Help.

Referer Redirect Help.
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jul 13, 2003, 11:05 AM
 
Hi was wondering if someone could help me with this.

I was looking to put a Javascript in the head of a page that would only allow the page to load for someone being redirect from a specific page in my site and redirect the others to another page in my site.

I did find this script:

Forum Questions:

Referer page
return to submit
forums

<!-- Original: Ronnie T. Moore, Editor -->
[!-- Begin
var refarray = new Array();
refarray['excite.com'] = "page.html?from=excite";
refarray['yahoo.com'] = "page.html?from=yahoo";
refarray['lycos.com'] = "page.html?from=lycos";
refarray['infoseek.com'] = "page.html?from=infoseek";
for (var i in refarray) {
if (document.referrer.indexOf(i) != -1) window.location.replace(refarray[i]);
}

but am not sure how it should or could be modified.

Any ideas?
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 13, 2003, 07:53 PM
 
for your qustion (making sure it comes from one place try:

Code:
if (document.referrer.indexOf("[the page they have to come from]") == -1) window.location.replace("[where to redirect them]");
replace [the page they have come from] and [where to rediret them] with valid locations

(the where they come from can be any part of where the other page is (/whatever/page.html, mydomain.com, mydomain.com/whatever, mydomain.com/whatever/page.html )

--hope that helps
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jul 14, 2003, 09:48 AM
 
Yes, Thank You, that helps with the original script I found above, but I guess I should explain what I'm doing. I have a password login page called LogIn.html and what I want to do is on the clients page that they log into (call it Client.html) I would like to prevent someone coming from somewhere else from directly accessing the page and to refer them to the LogIn page and anyone coming from the LogIn page to be allowed into their page. Hope I explained that correctly. It's kind of a week security validation in addition to the LogIn pages encoding and validation sscript.

So, ignoring the original script and using the code you have above, how would i word an:

IF they come from LogIn.html allow access to this page (Client.html), ELSE send them to the LogIn page.

It's kinda like the Force Frameset scripts out there.

I really appreciate your time and help! Thanks!
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 14, 2003, 09:59 AM
 
the code i provided should do that:

how it works:
if ( -- self explanitory
document.referrer.indexOf( -- does the page they are coming from conaint the following
"[the page they have to come from]" -- what page they came from
) == -1) -- this checks and sees if the answer is no (ie they didn't come from that page)

window.location.replace( -- then set the window location to the following
"[where to redirect them]" -- where to set the window location
);

in your case both [the page they came from] and [where to redirect them] would be the full path including domain name to login.html

--will
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:10 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2