I have a html page with no doctype declared deployed to a server(say A). This is fetching js files from another server(say B). js creates necessary html page to display. Now IE8 is creating problems as there is not doctype declared(sets itself to IE5 quirks mode)
Now doctype is the first line read, and this seems impossible to be done this way(using js to set the doctype). Is it possible to set a meta tag instead to set the page to standards mode? Or is there any other i can set the page to standard page without modifying the html page from server A.
I have a html page with no doctype declared deployed to a server(say A). This is fetching js files from another server(say B). js creates necessary html page to display. Now IE8 is creating problems as there is not doctype declared(sets itself to IE5 quirks mode)
Now doctype is the first line read, and this seems impossible to be done this way(using js to set the doctype). Is it possible to set a meta tag instead to set the page to standards mode? Or is there any other i can set the page to standard page without modifying the html page from server A.
Share Improve this question asked Feb 3, 2014 at 9:20 bhbbhb 2,5614 gold badges21 silver badges32 bronze badges 1- 2 stackoverflow./questions/tagged/x-ua-patible - however if you can set a meta tag you can set the doctype. Both have to be read at load time - also read this stackoverflow./questions/2518256/… – mplungjan Commented Feb 3, 2014 at 9:22
1 Answer
Reset to default 6var nodeDoctype = document.implementation.createDocumentType(
'html',
'-//W3C//DTD XHTML 1.0 Transitional//EN',
'http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtdd'
);
if(document.doctype) {
document.replaceChild(nodeDoctype, document.doctype);
} else {
document.insertBefore(nodeDoctype, document.childNodes[0]);
}
Update based on your ment:
It is possible to change the doctype with JS to enable patability viewing (as done here: http://www.webmasterworld./forum91/4856.htm) but is quite a nasty hack and not remended. Ideally you can do this server side. So have a doctype js parameter and then do a page reload:
window.location = window.location+"?doctype=newdoctype"
This will cause the page to reload which might not suit you, but is the safest way to do it.