sonic wrote:
thanks for quick response Randy.
What response? Why is top-posting becoming common here? Please
interleave replies with trimmed quotes from whatever you are replying
to. Now the conversation is completely out of sequence...
[...]
Randy Webb wrote:
sonic said the following on 7/10/2006 2:09 PM:
Ok,
i am sure everyone is sick of hearing about this. but i've checked
about 10 different posts/sites about this issue, and they all say "use
DOM" but i think there is more to be said. Perhaps I am a total newbie
but the answer was not immediately obvious to me here.
so.. problem:
declaring doctype as xhtml will prevent myDiv.innerHtml=val from
working.
It will fail using that capitalisation (perhaps you've not copied
actual code), but otherwise, why should it fail just because you are
using XHTML[1]? There is no public specification to say where, when or
how innerHTML should work, so test it widely before use.
The general idea is that innerHTML should only be used for simple
things - it is really handy to completely replace the content of an
element with a bit of text with minimal markup. It is also common to
use it with AJAX where large chunks of documents are returned for
insertion into a document, but I that doesn't make it good.
There are some big differences in implementations between browsers,
there is no published standard for it and it isn't (and likely never
will be) part of a W3C standard.
Only in browsers that support xHTML (IE doesn't).
Even using XHTML strict, Firefox allows the use of innerHTML without
complaint. I'd expect it to fail with XML, not XHTML. Afterall, XHTML
(1.0) is just HTML written as XML. 1.1 is somewhat different, but even
then innerHTML still works in Firefox (and IE).
[...]
and how come
myDiv.innerHTML = val // all caps HTML
still works?
In which browser?
IE and Firefox 1.5.
1. Whether it is 'better' to use XHTML rather than HTML has been argued
long and hard in many forums. The concensus is that unless you have a
really good reason to use XHTML and understand the ramifications, stick
with HTML. Otherwise, there are some significant down-sides and no
positives to XHTML.
--
Rob