【发布时间】:2011-07-26 01:39:43
【问题描述】:
当我运行以下代码时:
created_script=document.createElement('script');
created_script.src='/javascripts/jquery-1.4.2.js';
created_script.type='text/javascript';
$(document.getElementById('fancybox-frame').contentWindow.document.head).append( created_script);
脚本元素是在 iframe 父级的 head 标签中创建的,而不是在 iframe 的 head 标签中创建的。有谁知道如何解决这个问题以附加到 iframe 的头部标签?
【问题讨论】:
-
确保父母和孩子来自同一个域,否则同源策略将阻止它工作。
标签: javascript jquery html iframe cross-domain