a hef如何调用window.location.host 打开当前网页链接
<div class="reg"><strong>打开当前网址<a href="window.location.host">http://<script>document.write(window.location.host);</script>/</a></strong></div>
回复讨论(解决方案)
版主,当前测试网址是:http://localhost/1.html,我想通过HOST取localhost这域名主机打开进入主页
我用打开当前网址 结果打开时变成了http://localhost/localhost 我需要的是http://localhost/
呵呵,没注意你用的是 location.host
进入主页
不就行了,找那些麻烦干什么
呵呵,没注意你用的是 location.host
进入主页
不就行了,找那些麻烦干什么
因为我不想每次修改网站内容,所以弄成自动更新的。 就是我的网页内容有我的网站地址显示, 我就是想更换了域名,不用那么麻烦每次都去修改内容,让他自动获取现在的域名显示在网页上
进入主页 中有域名吗?
进入主页 中有域名吗?
有域名的
域名在哪?
window.location.host 是当前页的域名
浏览器会自己配上他
域名在哪?
window.location.host 是当前页的域名
浏览器会自己配上他
我网址的域名http://www.rocuo.cn
你用浏览器访问 http://www.rocuo.cn 时
那么 window.location.host 就是 www.rocuo.cn
访问的也是 http://www.rocuo.cn
你用浏览器访问 http://www.rocuo.cn 时
那么 window.location.host 就是 www.rocuo.cn
访问的也是 http://www.rocuo.cn
但是时间获取的是http://www.rocuo.cn/www.rocuo.cn 这样的










