作者 : darcy   时间 : 2015-09-25   浏览 : ...

执行下面一段代码:

//获取域名
var host0 = window.location.host;
var host1 = document.domain;

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

console.log("host0 = " + host0)
console.log("host1 = " + host1)
console.log("url = " + url)


结果(获取的是当前网站的域名):

host0 = www.seaxiang.com
host1 = www.seaxiang.com
url = http://www.seaxiang.com/




原创文章如转载,请注明本文链接: http://www.seaxiang.com/blog/js-get-domain
seaxiang  All Rights Reserved   粤ICP备15083047号-1