2

How can I add the following line to the header, in a component?

<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->
Mokus
  • 10,174
  • 18
  • 80
  • 122

2 Answers2

6

Not sure if it will work with any text, but you could try:

$document =& JFactory::getDocument();
$document->addCustomTag('<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->');

I hope it will be helpfull.

Ruslan Polutsygan
  • 4,401
  • 2
  • 26
  • 37
  • Actually your solution works http://docs.joomla.org/JDocumentHTML/addCustomTag I didn't know that we can use addCustomTag. Thumb up :) – Ahmad Alfy Aug 05 '11 at 16:23
1

You can use :

<?php
    $document = &JFactory::getDocument();
    $document->addScript( '/js/excanvas.min.js' );
?>

I am searching for how to add the conditional statement though ...

UPDATE

Checking if the user agent is IE

<?php
    $document = &JFactory::getDocument();

    //Is it Internet Explorer?
    ereg('MSIE ([0-9]\.[0-9])',$_SERVER['HTTP_USER_AGENT'],$reg);

    if(isset($reg[1])) {
        //Yes, it is Internet Explorer
        $document->addScript( '/js/excanvas.min.js' );
    }
?>
Ahmad Alfy
  • 13,107
  • 6
  • 65
  • 99