Thursday, April 12, 2007

nonstandard property :: innerHTML (but is a de facto standard)

The innerHTML property is not part of the DOM. It isn't part of any standard. It is a proprietary addition created by Microsoft.

Normally, I wouldn't recommend using anything proprietary in JavaScript code (although the XMLHttpRequest object itself is a proprietary addition). However, the innerHTML property is exceptionally well supported, considering that it is nonstandard. It is, in effect, a de facto standard: it is supported in all the major browsers. The reason why innerHTML has been so widely adopted, without any endorsement from the W3C, is that it is very useful in certain situations.

DOM methods allow you to manipulate a document very precisely. You can create elements, attributes, and text, one node at a time. That is very powerful, but it is also quite time-consuming.

The innerHTML property uses brute force. If you read the innerHTML property of an element, you will receive a string of HTML. This is a read/write property, meaning that you can also assign a string of HTML to go inside an element.

Any HTML that was previously inside the element will be obliterated and replaced with the contents of the string.

1 comment:

Jehzeel Laurente said...

i'm using godaddy, and until now my CNAME doesn't work, I followed the instructions of google step by step. Set the alias name to www and point it to ghs.google.com... huhuhuhu.. I hope u can help me to make it work :(