如何从joomla 2.5中的特定页面中删除元关键字标签

时间:2014-06-05 12:20:58

标签: jquery joomla

如何从joomla 2.5中的特定页面中删除元关键字标记。我需要从一页中删除它。但是,它将保留在其他页面上。我尝试过使用jQuery remove()函数,但它没有用。

这是脚本:

<script type="text/javascript">
                jQuery(function(){
                   jQuery("meta[name='keywords']").remove(); 
                });
            </script>

2 个答案:

答案 0 :(得分:3)

试试这个,

$document = JFactory::getDocument();
$document->setMetaData('keywords', "");
$document->setMetaData('robots', "");
$document->setMetaData('author', "");

有关详情about set meta data of Joomla Page

希望它有效。

答案 1 :(得分:0)

您可以通过JDocument类将其内容设置为空字符串来删除元标记。

例如:

$doc =& JFactory::getDocument();
$doc->setMetaData('description', '');

这将删除<meta name="description" ... >代码。

如果您可以访问所选模板的index.php,则可以直接使用$ this中的函数setMetaData:

$this->setMetaData('description', '');

如果您有兴趣,请参阅Joomla! API文档(搜索JDocument,然后搜索setMetaData):http://doc.joomladev.eu/api25/