T
Trev
Hi everyone,
I'm trying to modify an existing piece of Javascript that will enable a
redirect to a page based
on IP address and/or keywords in the referrer; for instance,
redirecting an existing member
to a page that bypasses introductory blurb etc. I've included the code
in an shtml file to allow
server side includes.
I've included the code below, but it doesn't work- it falls over at the
document.write("<META etc.
line, but I can't see why. Can anyone provide any clues?
Incidentally, would it be preferable to use use history.previous rather
than referrer?
Many thanks
Trev
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirect(){
var ip = '<!--#echo var="REMOTE_ADDR"-->';
s = new String(document.referrer);
var teststring1="Whizz";
var teststring2="Bang";
// test IP and referrer strings
if (ip == "x.x.x.x" || ip == "x.x.x.x" || ( s.test(teststring1) &&
s.test(teststring2))) {
document.write('<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=http://www.otherpage/members.html">');
}
}
redirect();
// End -->
</script>
</HEAD>
<!-- default page content here-->
I'm trying to modify an existing piece of Javascript that will enable a
redirect to a page based
on IP address and/or keywords in the referrer; for instance,
redirecting an existing member
to a page that bypasses introductory blurb etc. I've included the code
in an shtml file to allow
server side includes.
I've included the code below, but it doesn't work- it falls over at the
document.write("<META etc.
line, but I can't see why. Can anyone provide any clues?
Incidentally, would it be preferable to use use history.previous rather
than referrer?
Many thanks
Trev
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirect(){
var ip = '<!--#echo var="REMOTE_ADDR"-->';
s = new String(document.referrer);
var teststring1="Whizz";
var teststring2="Bang";
// test IP and referrer strings
if (ip == "x.x.x.x" || ip == "x.x.x.x" || ( s.test(teststring1) &&
s.test(teststring2))) {
document.write('<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=http://www.otherpage/members.html">');
}
}
redirect();
// End -->
</script>
</HEAD>
<!-- default page content here-->