js获取当前域名

  • 内容
  • 评论
  • 相关

js代码:


<script language="javascript">
//获取域名
host1 = window.location.host;
host2=document.domain;

//获取页面完整地址
host3= window.location.href;

document.write("<br>host1="+host1)
document.write("<br>host2="+host2)
document.write("<br>host3="+host3)
</script>


输入结果:


host=localhost
host2=localhost
url=http://localhost/test/wlphp.html

本文标签:这篇文章木有标签

版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。

本文链接:js获取当前域名 - http://wlphp.com/?post=21

发表评论

电子邮件地址不会被公开。 必填项已用*标注