views:

25

answers:

1

Just found that changing href dynamically can be implemented differently and one method with

 document.anchors[] =

works for FireFox and Chrome and does not for IE while using

 document.getElementById(..).setAttribute('href',

works for All. Is there a general rule for such changes that one can take for granted or is it always tag/param specific?

A: 
document.getElementsByTagName("a")

Works for all.

EDIT:

A precise detail can be read from here

How you can use it to get all the hyperlinks (anchors) of the page (or frames - depend on the window object context):

var links = document.getElementsByTagName("a");
for(var index=0; index<links.length; index++) {
// links[index].href = links[index].href + (links[index].href.indexOf("?") ? "&" : "?") + "hello";
}
Ramiz Uddin