【问题标题】:Replace by current domain替换为当前域
【发布时间】:2017-12-03 17:38:34
【问题描述】:

我有一个链接:http://fakedomain.net/path

我想用 当前域 名称动态替换链接,如下所示:http://currentdomain.com/path

$('.link a').each(function(){
    this.href = this.href.replace('http://fakedomaine.net/', WHAT_GOES_HERE);
});

但是我现在被屏蔽了

【问题讨论】:

    标签: jquery url href location-href


    【解决方案1】:

    试试这个

    this.href = this.href.replace('http://fakedomaine.net', 
    location.protocol+"//"+location.host);
    

    【讨论】:

    • 完美运行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    相关资源
    最近更新 更多