tags:

views:

32

answers:

3

document.all["" + object.getAttribute("EndDate", true) + ""].value;

does work in firefox but work in IE.

what is the alternative way other than the code above to work in multiple browsers?

A: 

Don't use document.all as it's non-standard. document.getElementById is the way to go.

mkluwe
+1  A: 

If you want to get the element by it's id use this form:

document.getElementById("elemen_id");

document.all isn't cross browser.

If you want to get an element's attribute use:

element.getAttribute("EndDate"); 

you don't need the .value property for that. The second parameter of getAttribute is not a boolean, rather an integer, and is only used in rare cases (like getting an element's href in IE). If you want case-sensitivity use 1, but true here is a bit confusing of what you want to do.

galambalazs
+1  A: 

document.all is a thing of the past and should be avoided . It is used to support IE4 ( which no one uses now a days ) . So unless you need to support IE4 , I think you should go ahead with document.getElementById which is supported by all browsers .

NM