How can I add custom code to the header
How can I add the following line to the header, in a componen开发者_高级运维t?
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->
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.
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' );
}
?>
精彩评论