旧Google AdSense代码的多个<script>标记的重要性</script>

时间:2013-09-16 20:06:45

标签: javascript html html5 script-tag

我正在使用Google AdSense内联脚本处理一些旧页面:

<script type='text/javascript'>
  GS_googleAddAdSenseService("ca-pub-1234123412345");
  GS_googleEnableAllServices();
</script>
<script type='text/javascript'>
  GA_googleAddSlot("ca-pub-1234123412345", "Header_728x90");
  GA_googleAddSlot("ca-pub-1234123412345", "TopCube_300x250");
  GA_googleAddSlot("ca-pub-1234123412345", "BottomCube_300x250");
</script>
<script type='text/javascript'>
  GA_googleFetchAds();
</script>

在重构此页面时,我想我会通过删除一些不需要的打开/关闭<script>标记来清理它:

<script type='text/javascript'>
  GS_googleAddAdSenseService("ca-pub-1234123412345");
  GS_googleEnableAllServices();
  GA_googleAddSlot("ca-pub-1234123412345", "Header_728x90");
  GA_googleAddSlot("ca-pub-1234123412345", "TopCube_300x250");
  GA_googleAddSlot("ca-pub-1234123412345", "BottomCube_300x250");
  GA_googleFetchAds();
</script>

我的修改后,Chrome会在控制台中报告错误:

  

未捕获的ReferenceError:未定义GA_googleAddSlot

我不明白原始代码和重构版本之间的显着差异。对于多个内联脚本标记,浏览器在这种情况下对单个标记执行的操作有何不同?

0 个答案:

没有答案