Is it possible to change the IE document mode with Javascript? I won't get into the nitty-gritty details here, but I'm fighting with a locked down Drupal site that will not allow me any acces to edit the theme files. Obviously, the correct thing to do would be to write something into the head, like this:
<meta http-equiv="X-UA-Compatible" content="IE=8">
But, as I mentioned, I have no access to that part of the page, so I'm hoping that I can use Javascript... sort of like this:
document.getElementsByTagName('head')[0].appendChild('<meta http-equiv="X-UA-Compatible" content="IE=IEVersion">');
Sadly, this doesn't work.
Is it possible to change the IE document mode with Javascript? I won't get into the nitty-gritty details here, but I'm fighting with a locked down Drupal site that will not allow me any acces to edit the theme files. Obviously, the correct thing to do would be to write something into the head, like this:
<meta http-equiv="X-UA-Compatible" content="IE=8">
But, as I mentioned, I have no access to that part of the page, so I'm hoping that I can use Javascript... sort of like this:
document.getElementsByTagName('head')[0].appendChild('<meta http-equiv="X-UA-Compatible" content="IE=IEVersion">');
Sadly, this doesn't work.
Share edited Mar 14, 2012 at 2:43 Lightness Races in Orbit 386k77 gold badges666 silver badges1.1k bronze badges asked Mar 15, 2011 at 20:18 SamSam 2,5656 gold badges34 silver badges48 bronze badges 5- 2 It'd be really nice if this were possible, but I fear it isn't. – Pointy Commented Mar 15, 2011 at 21:55
- do you have access to the web server? you could serve the X-UA-Compatible HTTP header with the page if so. – Matty F Commented Mar 16, 2011 at 11:23
- @matty I wish! No. Unfortunately, I have very limited access. Basically, I can't edit any Drupal files or theme files or add new ones. I can only interact with the structure of the site by way of Javascript. Sadly, I think this is a lost cause. – Sam Commented Mar 16, 2011 at 12:44
- 1 I think this header is rather useless given that you can deliver CSS fixes to specific versions of IE. What is the reason you're hoping to add it? – Matty F Commented Mar 18, 2011 at 1:17
- There is something somewhere very wrong, if you find yourself needing this. There's surely a better way. Perhaps you should expand on those "nitty-gritty details". – thirtydot Commented Mar 20, 2011 at 2:58
1 Answer
Reset to default 0That's a bit of a pickle you're in. What about this?
if (navigator.userAgent.indexOf("MSIE 7.0")) {
// add conditional css in here
} else {
// default css
}