S
S
Sergey750il2014-10-09 18:35:43
Drupal
Sergey750il, 2014-10-09 18:35:43

How to implement conditional comments for IE in Drupal 7 theme?

Hello. I ran into a problem that I can’t insert conditional comments into a Drupal 7 theme. I used to make sites on WordPress, there were no problems with this.
Pasted this code into html.tpl.php - doesn't work.

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

I also tried to load scripts not from CDN, but directly - it doesn't work. Maybe I didn't write the path correctly...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2014-10-21
@pantey

For a better browser detection, you can use this module , or rather the functions that it provides. Well, then through
or another hook that is responsible for generating the page, connect your script:

<?php
exampleModule_preprocess_html(&$variables){
if(условие){
drupal_add_js('путь до вашего скрипта');
}
}
;?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question