Javascript文档。在IE 8中编写

Javascript文档。在IE 8中编写,javascript,internet-explorer-8,object-expected,Javascript,Internet Explorer 8,Object Expected,这让我头疼,整天都在追它。我们有一个广告服务器,它在我们的站点上调用脚本,然后插入代码 例如。 在iframe中调用的Adserver页: <html> <head><title></title></head> <body> <script src="http://adserver/ad?s=728x90"></script> </body> </html> 上面的脚本调

这让我头疼,整天都在追它。我们有一个广告服务器,它在我们的站点上调用脚本,然后插入代码

例如。 在iframe中调用的Adserver页:

<html>
<head><title></title></head>
<body>
<script src="http://adserver/ad?s=728x90"></script>
</body>
</html>

上面的脚本调用返回的javascript:

document.write('<script type=\'text/javascript\' src=\'http://partner.googleadservices.com/gampad/google_service.js\'>\n');
document.write('</script>\n');
document.write('<script type=\'text/javascript\'>\n');
document.write('GS_googleAddAdSenseService("ca-pub-xxxxxxxxxxxxxxxxxxx");\n');
document.write('GS_googleEnableAllServices();\n');
document.write('</script>\n');
document.write('<script type=\'text/javascript\'>\n');
document.write('GA_googleUseIframeRendering();\n');
document.write('</script>\n');
document.write('\n');
document.write('<script type=\'text/javascript\'>\n');
document.write('GA_googleFillSlotWithSize("ca-pub-xxxxxxxxxxxxxxxxxx", "Global_728x90", 728, 90);\n');
document.write('</script>\n');
document.write('\n');
document.write('\n');
document.write('\n');
文件。写入('GS_GoogleAddSenseService(“ca-pub-XXXXXXXXXXXXXXXXX”);\n');
document.write('GS_googleEnableAllServices();\n');
document.write('\n');
document.write('\n');
document.write('GA_googleUseIframeRendering();\n');
document.write('\n');
document.write('\n');
document.write('\n');
文档。写入('GA_googleFillSlotWithSize(“ca-pub-XXXXXXXXXXXXXXXX”,“Global_728x90”,728,90);\n');
document.write('\n');
这将在我们的页面上插入谷歌广告管理器广告。问题是,该代码在IE7和IE8中不起作用,但在Chrome、Firefox、Safari等浏览器中效果良好

IE返回的“错误”是“预期对象”,通过IE的“开发工具”运行它也没有帮助

我已经尝试了很多方法来让它工作,把 似乎每次运行GS_u或GA_u函数时都会发生错误,所以我怀疑IE试图阻止外部脚本写入页面

谁能解释一下错误发生的原因或解决方案


谢谢

我想这仅仅是因为Chrome、Firefox、Safari等浏览器速度更快。他们正在下载文件
http://partner.googleadservices.com/gampad/google_service.js
在执行依赖于它的脚本之前,IE仍在拉取文件。
也许你可以把这个js文件的内容放在你自己的js中?

我想这仅仅是因为Chrome、Firefox、Safari等浏览器速度更快。他们正在下载文件
http://partner.googleadservices.com/gampad/google_service.js
在执行依赖于它的脚本之前,IE仍在拉取文件。
也许你可以把这个js文件的内容包含在你自己的js中?

自从发布这个问题以来,我已经看到了很多。据我所知,这是一个只存在于IE中的竞争条件问题。不幸的是,没有办法解决它。

自从发布这个问题以来,我已经看到了很多。据我所知,这是一个只存在于IE中的竞争条件问题。不幸的是,没有办法解决它