edit all hrefs in the page with jquery
there are hyperlinks in my page link this
<a href="home.php?id=2">some text</a>
<a href="http://myDomanin.com/home.php?id=3">some text</a>
<a href="http://myDomanin.com/home.php?id=4">some text开发者_开发技巧</a>
<a href="home.php?id=5">some text</a>
I want to write a javascript to change hrefs to this new link:
if OldHref = http://myDomanin.com/home.php?id=3
then
NewHref = http://myNewDomain.com/{base64Encode of OldHref}
found a plugin to make base64 encode here
$('a').each(function(){
this.href = 'http://myNewDomain.com/' + Base64Encode(this.href);
});
Or something of the sort...
Non, jQuery method:
var anchors = document.getElementsByTagName('a');
for (var a = 0; a < anchors.length; a++){
anchors[a].href = 'http://myNewDomain.com/' + Base64Encode(anchors[a].href);
}
精彩评论