jscript_junkie
07-27-2002, 06:36 AM
Hey all.
I found this on JavaScriptKit. It checks to see if the site accessing the data is your domain. I found it pretty cool.
//Beginning of "test.js" file
var accepted_domains=new Array("wsabstract.com","javascriptkit.com")
var domaincheck=document.location.href //retrieve the current URL of user browser
var accepted_ok=false //set acess to false by default
if (domaincheck.indexOf("http")!=-1){ //if this is a http request
for (r=0;r<accepted_domains.length;r++){
if (domaincheck.indexOf(accepted_domains[r])!=-1){ //if a match is found
accepted_ok=true //set access to true, and break out of loop
break
}
}
}
else
accepted_ok=true
if (!accepted_ok){
alert("You\'re not allowed to directly link to this .js file on our server!")
history.back(-1)
}
/////rest of your libray
"
"
"
The JavaScriptKit page containing this is at this address (http://www.javascriptkit.com/javatutors/externalrestrict.shtml)
Hope this is useful! :D
I found this on JavaScriptKit. It checks to see if the site accessing the data is your domain. I found it pretty cool.
//Beginning of "test.js" file
var accepted_domains=new Array("wsabstract.com","javascriptkit.com")
var domaincheck=document.location.href //retrieve the current URL of user browser
var accepted_ok=false //set acess to false by default
if (domaincheck.indexOf("http")!=-1){ //if this is a http request
for (r=0;r<accepted_domains.length;r++){
if (domaincheck.indexOf(accepted_domains[r])!=-1){ //if a match is found
accepted_ok=true //set access to true, and break out of loop
break
}
}
}
else
accepted_ok=true
if (!accepted_ok){
alert("You\'re not allowed to directly link to this .js file on our server!")
history.back(-1)
}
/////rest of your libray
"
"
"
The JavaScriptKit page containing this is at this address (http://www.javascriptkit.com/javatutors/externalrestrict.shtml)
Hope this is useful! :D