链接的代码如下:
<td class="buttonColumn">
<a href="javascript:confirmDialog('Are you sure you want go?', 'http://google.com');" class="actionButtonNew">Leave to Google</a>
</td>
<td class="buttonColumn">
<a href="javascript:confirmDialog('Are you sure you want go?', 'http://yahoo.com');" class="actionButtonNew">Leave to Yahoo</a>
</td>
页面上有多个按钮,格式完全相同,也需要更改。我在想这样的事情:
var fix = document.getElementsByClassName('actionButtonNew');
for (var i=0; i<fix.length; i++) {
我不确定如何完成代码。我试过这个:
var fix = document.getElementsByClassName('actionButtonNew');
for(var i = 0; i < fix.length; i++) {
try {
var l = fix[i];
var h = fix[i].parentNode.getElementsByClassName('actionButtonNew')[0].href.replace("javascript:confirmDialog('Are you sure you want to go?',", "");
l.href = h;
} catch(e) {}
}
我知道这是非常混乱和糟糕的。它确实将链接更改为:' http: //google.com ');
所以我想我可能走在正确的轨道上。请帮我。提前致谢!