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.
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.
I don't think you can. doctype
is listed as a property in the W3C documentation, but it's read-only. Even if it weren't, I can't imagine what effect changing it would have in real-world browsers.
Re your subsequent comments: You'd have to handle this server-side and serve back the page tailored to the target browser. But you shouldn't have to do that in any but some very fringe cases.
document.doctype is a read-only
property, not method, apparently according to MDC.
What you need is:
https://developer.mozilla.org/En/DOM/DOMImplementation.createDocumentType
Returns a DocumentType object which can either be used with DOMImplementation.createDocument upon document creation or they can be put into the document via Node.insertBefore() or Node.replaceChild():
Even if you could, your code would be executing after the page has already decided to render by which case the effect of changing the doctype is nothing. The only way I can imagine modern browsers having doctype issues is that you are relying on quirks mode in IE - fix your design to work for all browsers but IE, then look at IE specific styling.