host = window.location.host
host2=document.domain
if(host!="xxx.com") alert("illegal")
您好!很高兴为您答疑!您试下这个:
<script language="javascript">
//获取域名
host = window.location.host
host2=document.domain
//获取页面完整地址
url = window.location.href
document.write("<br>host="+host)
document.write("<br>host2="+host2)
document.write("<br>url="+url)
</script>
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。