在Joomla中加载脚本标记的问题

时间:2016-11-22 16:03:33

标签: javascript php joomla joomla3.0

我在Joomla 3.3.6中面临脚本问题。我有加载广告的脚本

    <script type="text/javascript">
  ( function() {
    if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
    var unit = {"calltype":"async[2]","publisher":"publisher","width":728,"height":90,"sid":"Chitika Default"};
    var placement_id = window.CHITIKA.units.length;
    window.CHITIKA.units.push(unit);
    document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>

在页面加载时,它将显示如下:

'); }());

我已删除Joomla编辑器过滤,脚本正确存储在数据库中。

2 个答案:

答案 0 :(得分:1)

我得到了解决方案

     <script type="text/javascript">
  ( function() {
    if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
    var unit = {"calltype":"async[2]","publisher":"publisher","width":728,"height":90,"sid":"Chitika Default"};
    var placement_id = window.CHITIKA.units.length;
    window.CHITIKA.units.push(unit);
    document.write('<div id="chitikaAdBlock-' + placement_id + '"/>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>

Div代码关闭错误

document.write('<div id="chitikaAdBlock-' + placement_id + '"/>');

而不是

document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');

答案 1 :(得分:0)

<script type="text/javascript">
  ( function() {
    if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
      var unit = {"calltype":"async[2]","publisher":"publisher","width":728,"height":90,"sid":"Chitika Default"};
      var placement_id = window.CHITIKA.units.length;
      window.CHITIKA.units.push(unit);
      document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
})();

使用它。你在}()); 中犯了一个错误。已更改})();