js获取当前域名和当前页面地址的方法

<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>
 
出处:http://houfeng.cnblogs.com
posted @ 2011-10-27 09:35  长风freedom  阅读(782)  评论(0)    收藏  举报