Reputation: 41
I have datatable rows links coming with data and I wanna change part of the link text.
So, for example, when it's 200.0.0.10
change it to 160.11.10.12
I tried it with this code but nothing happened, the link remains unchanged:
var url = (data['Chemin'])
window.location.href = url.replace("http:\\200.0.0.10", "\\160.11.10.12\Images");
Upvotes: 1
Views: 173
Reputation: 586
Use //
in your url and it should work.
window.location.href = url.replace("http:\\200.0.0.10", "http://160.11.10.12/Images");
If that doesn't work it's because of the escaped backslashes so do:
window.location.href = url.replace("http:\\\\200.0.0.10", "http://160.11.10.12/Images");
Using backslashes \
in JS is an escape character which means that the next character has special meaning e.g. \n
means new-line. So if you want a \
in a string you have to double it.
Upvotes: 1