I have this URL :
I want to have this :
http:\ /\ /example.com\ /example\ /sample\ /example.jpg
I wrote this code :
function addslashes(str) {
return str.replace('/', '\/');
}
var url = http://example.com/example/sample/example.jpg
var t = addslashes(url);
alert(t);
As an alert, I still get the old URL. What's wrong with this code? Thanks.
.replace(/\//g,'\\/')'\/' === '/'