By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Redirect someone from a referring domain to a webpage

P: n/a
Hi all,
I'm trying to redirect users from a specific domain to one of my
webpages.
So, in my example, anyone accessing my index.html from the
*btinternet.com domain (allowing for wildcards!) will be redirected to
"update.htm".

I'm not bothered what the referring webpage was, I'm just interested
in
anyone accessing my page from a certain domain

This is what I have:

<HTML>

<HEAD>
<script type="text/javascript">
function redirect()
{
previousDomain = document.referrer

if(previousDomain.indexOf("btinternet.com") > -1)
{
window.location="update.htm"
}
}
</script>

</HEAD>

....snip.....

<BODY bgcolor="FFFFFF" TEXT="000000" LINK="00FF00"
onload="redirect()">

......snip......
but it doesn't want to work.... what have I done wrong?

Best wishes

Paul
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello

It looks OK. If you do an alert of document.referrer, do you see what you
expect?

Does this help?

http://devedge.netscape.com/library/...3/reference/do
cument.html#1193980

You should convert the referrer to lower (or upper) case before attempting
comparisons:
document.referrer.toLowerCase();

Mark

"Paul Lee" <pa**@paullee.com> wrote in message
news:cf**************************@posting.google.c om...
Hi all,
I'm trying to redirect users from a specific domain to one of my
webpages.
So, in my example, anyone accessing my index.html from the
*btinternet.com domain (allowing for wildcards!) will be redirected to
"update.htm".

I'm not bothered what the referring webpage was, I'm just interested
in
anyone accessing my page from a certain domain

This is what I have:

<HTML>

<HEAD>
<script type="text/javascript">
function redirect()
{
previousDomain = document.referrer

if(previousDomain.indexOf("btinternet.com") > -1)
{
window.location="update.htm"
}
}
</script>

</HEAD>

...snip.....

<BODY bgcolor="FFFFFF" TEXT="000000" LINK="00FF00"
onload="redirect()">

.....snip......
but it doesn't want to work.... what have I done wrong?

Best wishes

Paul

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.