[Javascript] detect application/xhtml+xml?
liorean
liorean at gmail.com
Tue May 9 14:44:08 CDT 2006
On 09/05/06, Steve Clay <sclay at ufl.edu> wrote:
> Does anyone know of a way to detect via JS whether or not the document was
> served as "application/xhtml+xml"?
Well, not really answering that exact question, but answering whether
the document has an 'html' element as root and is in XML mode (using
the fact that the HTML DOM uppercases all tag names.):
var
isXHTML=/^html$/.test(document.documentElement.tagName);
There are two different possibilities if isXHTML is false:
- Document is parsed as HTML instead of as XML. (typically served as
'text/html')
- Document is parsed as XML but does not have an 'html' element for root.
It also has a false positive, in that the document may be XML and have
an 'html' element for root, but doesn't have the correct XHTML
namespace.
--
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>
More information about the Javascript
mailing list