Skip to content

Instantly share code, notes, and snippets.

@wishfoundry
Last active December 29, 2015 01:19
Show Gist options
  • Save wishfoundry/7591996 to your computer and use it in GitHub Desktop.
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!
<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>
@wishfoundry
Copy link
Author

doesn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment