Lea*_*RoR 4 javascript google-maps ruby-on-rails facebox
在我的Ruby on Rails应用程序中,我使用Facebox插件进行Ajax弹出窗口.我有2页叫做add_retail_stores/new.html.erb
和add_retail_stores/new.js
.该new.js
页面继承了new.html.erb
页面中的所有元素,因此它看起来完全相同.我在HTML页面上有一个Google地图脚本,可以正常工作.但是new.js
在我的不同页面上弹出的页面叫做add_store_prices.html.erb
page(<%= link_to add_retail_store_path, :remote => true %>
)
我收到错误:
警告:忽略了从异步加载的外部脚本调用document.write().源文件:http:// localhost:3000/add_store_prices 行:0
我相信因为它试图通过2个函数/脚本.第一个是Facebox,然后是Google脚本.有谁知道如何处理这个错误?
我相信Facebox插件正在使用,document.write
但我不确定在哪里,也许在我的页面上的这两行之一?
new.js:
$.facebox('<%= escape_javascript(render :template => 'business_retail_stores/new.html') %>')
$('#facebox form').data('remote','true');
Run Code Online (Sandbox Code Playgroud)
Mar*_*c B 11
不要使用document.write.该脚本是异步加载的,这意味着它与文档解析状态分离.对于JS引擎来说,确实知道应该在页面中执行document.write是非常方便的.
外部脚本可以即时加载,document.write可以在<script src="...">
标记所在的位置执行,也可以在net.burp中运行并在一小时后加载,这意味着document.write会在页面末尾标记.它确实是竞争条件,因此JS引擎将忽略异步加载的脚本中的document.writes.
转换document.write以使用常规DOM操作,由document.onload
类型处理程序保护.