错误:无法从异步加载的外部脚本写入文档
Error: It isn't possible to write into a document from an asynchronously-loaded external script
我试图在rails 4网站上加载广告,并不断获得以下错误
onejs?MarketPlace=US&adInstanceId=xxxxxxxx&storeId=xxxxxxx:1 Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
如果我刷新页面,广告加载正常。下面是来自amazon的广告代码,它位于show.html.erb文件中。
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=xxxxxxxxx&storeId=xxxxxxxx"></script>
如果我使用亚马逊广告与Iframe代码没有问题,但这种格式的广告没有Iframe选项(这是原生广告-扫描页面的相关内容显示广告)
这是一个rails 4站点,在heroku上启用了涡轮链接。我完全不知道该如何修理它。adwords和media.net广告也是如此。
知道怎么解吗?
这个库可以解决您的问题https://github.com/krux/postscribe
异步编写javascript,即使使用document.write.
<div id="ad"><h5>Advertisement</h5></div>
<script type="text/javascript">
// jQuery used as an example of delaying until load.
$(function() {
// Build url params and make the ad call
postscribe('#ad', '<script src=doubleclick_url_with_params><'/script>');
});
</script>
相关文章:
- 如何在运行时在angular 2中加载外部js脚本
- 是否可以通过Chrome扩展内容脚本打开Chrome外部协议请求
- 建议将包含不同参数的内联JS转换为外部脚本
- 加载Angular视图后加载外部脚本
- 如何获取外部脚本的内容
- 是否有用于加载外部脚本的JavaScript库
- Chrome审核:在外部CSS文件之间的头中发现了1个内联脚本块&”;
- 我的代码在<脚本>标记,但没有'不能在外部文件中工作
- Javascript:是否可以读取外部脚本的原始代码
- 从外部 js 脚本创建元素并插入到 html 中
- 将参数传递到外部 JS 脚本的最佳方法
- 不评估动态加载的外部脚本
- 外部脚本可以在Schematron规则中使用吗
- Ajax和外部JS脚本
- 在Ember应用程序中加载外部域脚本
- Kinetic JS无法从外部脚本文件中工作
- 谷歌应用程序脚本:如何使用电子表格中的数据查询外部数据库
- JavaScript - 是否可以修改第三方脚本(外部托管)使用的 setInterval/setTimeout 的行为
- javascript函数从编写的脚本外部调用是安全的吗?
- 从脚本外部调用内部铯函数