Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i change the DOCTYPE

anyone here know how i can dynamically change the doctype with javascript?

i have tried with this function,

document.doctype('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'); ,

but it does not work.

like image 619
mana Avatar asked Jun 30 '10 08:06

mana


1 Answers

I hope this one might help some of you ( Tested in Console and it changes actual DOCTYPE)

var newDoctype = document.implementation.createDocumentType(
 'html',
 '-//W3C//DTD XHTML 1.0 Transitional//EN',
 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdd'
);

document.doctype.parentNode.replaceChild(newDoctype,document.doctype);
like image 95
Akash Saikia Avatar answered Sep 18 '22 22:09

Akash Saikia