var t_u = window.location.host
var arydomain = new Array("www.baidu.com", "www.qq.com", "www.163.com")
for (i = 0i <arydomain.lengthi++) {
if (t_u == arydomain[i]) {
setTimeout("location.href='http://www.163.blog.com'", 0)
return
}
}
}
//获取域名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>故意断开的,否则程序会不正常。