Mathieu
Mathieu

Reputation: 761

Replace by current domain

I have a link : http://fakedomain.net/path

I want to replace dynamically the link with the current domain name like this : http://currentdomain.com/path

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

But I am blocked at this point

Upvotes: 0

Views: 234

Answers (1)

mplungjan
mplungjan

Reputation: 177940

Try this

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

Upvotes: 2

Related Questions