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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Must Vist From..." JavaScript

Status
Not open for further replies.

LadyYepperz

Programmer
Oct 2, 2008
3
US
Please help me with this script. I've tried repeatedly to get this script to work. If a subpage (page2) on my site is linked directly, this script is suppose to redirect the browser to the home page (page1). But when page2 IS opened from page1, instead of showing page2, it directs the browser back to page1.

Still with me?

page2 opens up in a new window.
it opens as its suppose to, but it shows page1 with
the address bar showing the address for page2
so im REALLY confused!

here is an example of whats going on...



************************************

Script Name: Must Visit From...

Description: If other sites links directly the sub-pages of your site or if previous required pages are being skipped, you can now require your visitors to come from a certain page! Those that did not come from the required page are alerted then sent back to the required previous page. Clever!


<!-- ONE STEP TO INSTALL MUST VISIT FROM....:

1. Copy the coding into the HEAD of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
var requiredfrom = "index.html"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("You must come to this page from " + requiredfrom);
window.location=requiredfrom;
}
// End -->
</script>

************************************


Thanks in advance for your help.
 
Hi

That will not work like that on Geocities. To add their ads they force your document into a frameset. So your second page's [tt]referrer[/tt] will be the frameset document around it.

As an alternative you could use cookies.

Even better, give up with this idea.


Feherke.
 
Thank you for your replies... but i only used that site as an example of what problem im dealing with. it will not be the host for my site... lol


@feherke
... are you saying that the script wont work inside frames?
 
@ feherke

thanx for trying to help me... i really appreciate it.
ive now found an alternative to using that script.

hopefully it wont take long for my hair to grow back in the places i pulled it out by the handfulls while trying to get that script to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top