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