is 'innerHTML' a W3C standard
on the web you can find many things about 'innerHTML'. As far as I know it works in all browsers (on divs and spans for sure). Most/all of these posts are old, so I was wondering: Is it a W3C standard ? and (if not) are there still issues with innerHTML ?
No, innerHTML is not a standard W3C DOM method. It is an IE specific method. But it is crossbrowser so far, as it has proved its efficiency mainly in some simple AJAX applications.
BUT!: innerHTML will not always insert all the elements nor all their attributes into the DOM tree. Nor even in IE browsers! That means sometimes an element (or its attributes) inserted with innerHTML can not be referred later on using DOM methods.
As a general rule: you may use innerHTML when you want simply to display new elements on the document. If you need further DOM handling, you should use standard DOM methods: createElement(), createTextNode(), setAttribute(), appendChild(), and so on... Even so, take care: IE has sometimes his own vision about the way some of those methods are to be applied.
Last edited by Kor; 11-18-2009 at 10:24 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)