js取得当前url,javascript获取当前页面url值,js获取域名
如果获取“当前”域名
host = window.location.host;
url=document.domain;
url = window.location.href;
取得完整url路径: 用以下代码可以完整研证结果:
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;
运行如下: 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]
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
- 访问:673792次
- 积分:14927分
- 排名:第137名
- 原创:659篇
- 转载:1161篇
- 译文:0篇
- 评论:209条
|