View Full Version : Making the user go to your home pahe
ldsnodden
11-10-2002, 12:03 PM
Hi, is there any way I can make users go to my web page. I.e. so that they have to go to my web page to get into any other links?
http://www.chesterfieldra.wtcsites.com/home.htm
whammy
11-10-2002, 11:49 PM
Do a search of the forums for some cookie posts - I can't find any directly relating offhand, but basically if you set a cookie with the path as your root directory ("path=/") only when someone visits your homepage, then you can check for the cookie on your other pages, and if it's not there, redirect them to your home page.
:)
glenngv
11-11-2002, 07:56 AM
or you can check document.referer. If this is empty, this means that the user goes directly to one of your pages, so redirect them to your home page. You may also want to check if the referrer is in the same domain as yours.
<head>
<script language="javascript">
if (document.referrer.indexOf("http://www.chesterfieldra.wtcsites.com")==-1){
location.href="http://www.chesterfieldra.wtcsites.com/home.htm";
}
</script>
</head>
whammy
11-11-2002, 11:38 PM
You know, I thought about mentioning document.referrer as well, but I had some imaginary idea it wouldn't work for his request. :)
That's perfect if you only want to make sure they came to a page from your site, because if you have that code on every page, the first page of yours they run into should kick them to the front page.
Anyway... what glenn wrote should work perfectly, but if you care about making that XHTML compatible you might to change it slightly:
<script type="text/javascript">
<!--
if (document.referrer.indexOf("http://www.chesterfieldra.wtcsites.com")==-1){
location.href="http://www.chesterfieldra.wtcsites.com/home.htm";
}
// -->
</script>
I'm trying to get out of the habit of using the "language" attribute myself.
P.S. Good correction, Glenn, I dunno what I was smoking last night, lol!
chrismiceli
11-12-2002, 01:53 PM
what is wrong with the language attribute?
joh6nn
11-12-2002, 02:03 PM
well, language isn't valid in XHTML, as i understand it, and if i recall correctly, it's been deprecated in HTML 4.01, too. personally, i just use
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
and don't bother with anything in my script tags.
whammy
11-12-2002, 11:22 PM
Ahh... hadn't considered that. Good one. :)
And yeah, John's right...
<script language="javascript"> isn't valid in XHTML.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.