使用jquery编辑页面中的所有HREF

使用jquery编辑页面中的所有HREF,jquery,href,Jquery,Href,“我的网页”中有超链接此链接 <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 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>

我想编写一个javascript将hrefs更改为这个新链接:

如果
OldHref=
,则

NewHref={base64Encode of OldHref}

找到一个使base64编码的插件

或者类似的东西


非,jQuery方法:

var anchors = document.getElementsByTagName('a');
for (var a = 0; a < anchors.length; a++){
  anchors[a].href = 'http://myNewDomain.com/' + Base64Encode(anchors[a].href);
}
var-anchors=document.getElementsByTagName('a');
对于(var a=0;a
var anchors = document.getElementsByTagName('a');
for (var a = 0; a < anchors.length; a++){
  anchors[a].href = 'http://myNewDomain.com/' + Base64Encode(anchors[a].href);
}