Last active
December 29, 2015 01:19
-
-
Save wishfoundry/7591996 to your computer and use it in GitHub Desktop.
Having trouble with xml based templating engines that don't allow you to declare a modern doctype? Use this little snippet to dynamically switch it to something sane!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function switchToHTML5() { | |
// create an html5 doctype | |
var newDoctype = document.implementation.createDocumentType('html', '', ''); | |
if (document.doctype) { | |
document.doctype.parentNode.replaceChild(newDoctype, document.doctype); | |
} else { | |
var currentHtml = document.head.parentNode; | |
currentHtml.parentNode.insertBefore(newDoctype, currentHtml) | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesn't work