开发者

How can I add custom code to the header

开发者 https://www.devze.com 2023-03-26 08:40 出处:网络
How can I add the following line to the header, in acomponen开发者_高级运维t? <!--[if lt IE 9]><script language=\"javascript\" type=\"text/javascript\" src=\"js/excanvas.min.js\"></scr

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' );
    }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号