How to add conditional HTML meta tag using drupal_add_html_head to force only IE9 into compatibility mode? Long story short: Some quite nice interative SVG map works fine on every major web browser thanks to svgweb. Except IE, of course. Every IE (8, 9, 10) needs a particular workaround. IE9 would only work when I force it into compatibility mode. Unfortunately I can't find a way to use drupal_add_html_head with #tag' =&gt; meta and #prefix and #suffix to only take effect in IE9. drupal_add_html_head works fine, but #prefix and #suffix discard it. So that doesn't work:

$meta_ie_render_engine = array(
  '#type' =&gt; 'html_tag',
  '#tag' =&gt; 'meta',
  '#attributes' =&gt; array(
    'http-equiv' =&gt; 'X-UA-Compatible',
    'content' =&gt;  'IE=7',
  ),
  '#weight' =&gt; '-99999',
  '#prefix' =&gt; '&lt;!--[if IE 9]&gt;',
  '#suffix' =&gt; '&lt;![endif]--&gt;',
);
drupal_add_html_head($meta_ie_render_engine, 'meta_ie_render_engine');


Is there another way to use drupal_add_html_head with tag =&gt; meta conditionally? Or another drupal-like alternative?
Had similar problem:

function detect_ie() {
    if (isset($_SERVER['HTTP_USER_AGENT']) &amp;&amp; (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
        return true;
    }
    else {
        return false;
    }
}


above will detect if IE in general. You will need to change 'MSIE' accordingly (something  like 'MSIE9' but not sure if thats correct).

Then what i did was 

if(detect_ie()) {
  $element = array(
  '#tag' =&gt; 'meta',
  '#attributes' =&gt; array(
  'http-equiv' =&gt; 'X-UA-Compatible',
    'content' =&gt;  'IE=EmulateIE7',
     ),
  );
drupal_add_html_head($element, 'IE_cr_ap');
}