I'm really quite new to programming and am trying to make a bookmarklet that will replace a character in a certain part of a url.
It would be something that would turn a url from this:
http://google.com/go/for/it/changethis.html
to
http://google.com/go/for/it/crangethis.html
where the h in the last part of the url is replaced with an r.
So far I have this:
javascript:
var url = new String(window.location);
var parts = url.substr(7).split('/', 5);
parts[4].replace(/h/, "r");
window.location = 'http://' + parts[0] + '/' + parts[1] + '/' + parts[2] + '/' + parts[3] + '/' + parts[4];
Everything works fine except for the " parts[4].replace(/h/, "r"); " line, which doesn't seem to do anything.
I know practically nothing about javascript so please be gentle when telling me I'm an idiot
Thanks
,
whatisthe
It would be something that would turn a url from this:
http://google.com/go/for/it/changethis.html
to
http://google.com/go/for/it/crangethis.html
where the h in the last part of the url is replaced with an r.
So far I have this:
javascript:
var url = new String(window.location);
var parts = url.substr(7).split('/', 5);
parts[4].replace(/h/, "r");
window.location = 'http://' + parts[0] + '/' + parts[1] + '/' + parts[2] + '/' + parts[3] + '/' + parts[4];
Everything works fine except for the " parts[4].replace(/h/, "r"); " line, which doesn't seem to do anything.
I know practically nothing about javascript so please be gentle when telling me I'm an idiot
Thanks
whatisthe