如何将自定义代码添加到标头

发布于 2024-11-28 03:33:15 字数 191 浏览 4 评论 0原文

如何将以下行添加到组件中的标题中?

<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->

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]-->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

送舟行 2024-12-05 03:33:15

不确定它是否适用于任何文本,但您可以尝试:

$document =& JFactory::getDocument();
$document->addCustomTag('<!--[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.

橘亓 2024-12-05 03:33:15

您可以使用:

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

我正在搜索如何添加条件语句...

更新

检查用户代理是否是 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' );
    }
?>

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' );
    }
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文