你应该在服务器端进行域名授权还好些
况且,js存在浏览器兼容问题,在每种浏览器、每种版本的浏览器下,对js的解析都有差异
//获取域名host = window.location.host
host2=document.domain
if(host!="xxx.com") alert("illegal")
能够办到的,JS里面location.href表示当前页面的完整地址,可以通过这个判断,例子代码如下:<script language=javascript>
//document.write(location.href)
if (location.href.substr(0,15)=='http://abc.com/') document.write('<script src="http://xxx.com/file.js"></s'+'cript>')
</script>
注意,我里面的</script>故意断开的,否则程序会不正常。