We're talking about XHTML 1.1 actually being served as application/xml+xhtml. The browser is parsing the XHTML document using the XML parser, and .innerHTML is an invalid attribute/DOM property in XHTML. While it may be valid in HTML 5.0, it is not valid and generates an error when the browser uses its XML parser. So yes, felgall is right.
1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.
Does anyone here have a link to a tutorial on the correct xhtml method for doing innerHTML rewrites?
"Strict" XHTML deprecates Javascript methods like document.write() and write access to the .innerHTML property, because they can be used to insert invalid code that would break the document structure. (Nice, hey?)
For example, if you could make a call like someDiv.innerHTML = '<p>look! invalid-ness!';, that would invalidate your document and break the page which has already rendered. To get around the lack of innerHTML however, DOM methods such as createElement() and createTextNode() do the trick. A bit more verbose, but valid under this XML-typed document.
Here are some examples on how to create content using createElement and createTextNode:
Step 1: Use HTML 4.01 Strict Doctype
Step 2: ????
Step 3: Profit
XHTML is an unsupported standard, and serving it as HTML is in fact the same as serving invalid HTML. Unless your serving it as `application/xhtml+xml` , there is no need for it.
To get around the lack of innerHTML however, DOM methods such as createElement() and createTextNode() do the trick. A bit more verbose, but valid under this XML-typed document.
Well you have to use createElementNS() with application/xhtml+xml don't you?
You can't serve XHTML 1.1 as HTML, it has to be served as XHTML and so you must use createElementNS() to add elements to the page.
You can serve XHTML 1.0 as HTML provided that you comply with the provisions in Appendix C. If you are going to selectively serve it as HTML or XHTML depending on whether the browser supports XHTML then you would need to test in the JavaScript for whether createElement or createElementNS is the appropriate call to use depending on which it is served as. If you are just going to serve it as HTML then it is effectively just slightly malformed version of HTML 4.01 that you are using.
HTML supports both document.write (before the page finishes loading) and innerHTML neither of which are supported by XHTML.
The HTML 5 standard is at least 10 years away from being implemented and so unless you are involved in the actual discussions on what it should include there is no reason for taking that version into consideration yet
Bookmarks