0

What would be your take on Doctype version detection. One solution comes to mind – feature detection, but is that the correct way to go? What I need in particular is to know wether the document is HTML4, XHTML (don't need the version) or HTML5.

Ideas?

Oskar Krawczyk
  • 3,492
  • 17
  • 20
  • 2
    Duplicate: http://stackoverflow.com/questions/1987493/read-doctype-with-javascript – Pekka Jan 09 '10 at 18:20
  • 1
    As in that question, you can look for the `DocumentType` node to find out for sure, except on IE where it mis-parses a doctype as a comment, which you then have to examine using crude text-searching hacks. Feature-detection would absolutely be better, but what feature are you looking for? Browsers will typically treat HTML4.01-Strict, XHTML1.0-Strict and HTML5 documents identically. – bobince Jan 10 '10 at 00:46

1 Answers1

0

It's not really universal, but: http://bytes.com/topic/javascript/answers/520145-doctype-detector

myfreeweb
  • 971
  • 1
  • 13
  • 19