标题:js取得url, javascript获取当前页面url值, js获取域名 出处:Felix021 时间:Tue, 20 Nov 2007 20:07:31 +0000 作者:felix021 地址:https://www.felix021.com/blog/read.php?418 内容: js取得当前url,javascript获取当前页面url值,js获取域名 转自http://hi.baidu.com/educast/blog/item/6f57d6ca80e7e744f21fe7b0.html 如果获取“当前”域名 host = window.location.host; url=document.domain; url = window.location.href; 取得完整url路径: 用以下代码可以完整验证结果: [codes=xml] thisDLoc = document.location;
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
[/codes] 运行如下: thisURL: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisHREF: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisSLoc: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisDLoc: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisDLoc = document.location; thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisTLoc: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisPLoc: [http://www.sinoeb.cn/js/js%BB%F1%C8%A1url.html] thisTHost: [www.sinoeb.cn] thisHost: [www.sinoeb.cn] thisTLoc = top.location.href; thisPLoc = parent.document.location; thisTHost = top.location.hostname; thisHost = location.hostname; thisHPage: [js%BB%F1%C8%A1url.html] thisUPage: [js%BB%F1%C8%A1url.html] Generated by Bo-blog 2.1.0