PDA

View Full Version : making room for multiple names


cunning-fox
09-02-2002, 12:14 AM
Hi,

This script was posted a short while ago on this forum. It simply prevents visitors from visiting a page, if they are visiting it using their host name. Since I'm not going to be able to test this on 2 separate domains, I'm wondering if this syntax would work to allow more than one domain (below 1st script).



<script>
if (location.hostname!="www.geocities.com") {
alert("The site that has linke you to this is not authorized. You now will be forwarded to the original site");
location.replace("index.htm");
}
</script>



<script>
if (location.hostname!="www.paypal.com,www.mydomain.com") {
alert("The site that has linke you to this is not authorized. You now will be forwarded to the original site");
location.replace("index.htm");
}
</script>



Thanks

beetle
09-03-2002, 03:47 PM
You just need the OR operator, which in javascript is a double pipe - ||if (location.hostname!="www.geocities.com" || location.hostname!="www.mydomain.com") { Note, the AND operator is a double ampersand - && - but you will want to use || for this script.

joh6nn
09-03-2002, 05:11 PM
um...

that's not gonna help you whole bunches of lot. location always referrs to the current url, not the one that you just came from. so you're checking to see if the page you're at now is geocities.com, or paypal.com.

if you want to check where people came from, you have to check the document.referrer property.

if (document.referrer!="www.geocities.com" || ldocument.referrer!="www.mydomain.com") {

beetle
09-03-2002, 05:14 PM
thanks joh6nn, I totally overlooked that and just focused on the operator question...