现在的位置: 首页 > 综合 > 正文

js取得当前url,javascript获取当前页面url值,js获取域名

2013年09月13日 ⁄ 综合 ⁄ 共 4472字 ⁄ 字号 评论关闭

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条
    文章分类
    推荐文章

      最新评论
      计算流量

    抱歉!评论已关闭.