This is in continuation of the question:
http://stackoverflow.com/questions/1801960/innerhtml-working-in-ff-but-not-in-ie
The above problem is resolved [ thanx to pygorex1 ] . But i would like to know why the following code snippet is not working.
if (window.addEventListener){
window.addEventListener('load', addDateFormatInfo, false);
window.addEventListener('load', loadNewElements, false);
} else if (window.attachEvent){
window.attachEvent('onload', addDateFormatInfo);
window.attachEvent('onload', loadNewElements);
}
function loadNewElements(){
document.createElement("showDateFormat");
}
function addDateFormatInfo(){
var dateFormatHolder = document.getElementsByTagName("showDateFormat");
if ( dateFormatHolder ){
for ( i = 0 ; i < dateFormatHolder.length; i++ ){
dateFormatHolder[i].innerHTML = '<div class="infoSmall" ><span>(mm/dd/yyyy)</span></div>';
}
}
}
provided it is working in FF but not in IE
also, if instead of creating a new method loadNewElements
and attaching this to load the event if i will directly write document.createElement("showDateFormat");
in my javascript [ not in any method ], then the code works as expected [ both in IE and FF ]. Why it is so?