// Use ckeditor created a iframe dom.
var iframe_node = new CKEDITOR.dom.element('iframe');
var iframe_styles = {
'font-size':'inhert',
'z-index':'10030',
'position':'absolute',
'left':'250px',
'top':'50px',
'width':'505px',
'height':'441px'
};
iframe_node.setStyles(iframe_styles);
// Append iframe to cke_dialog
jQuery(iframe_node.$).appendTo('.cke_dialog');
var seciframecon = jQuery('.cke_dialog').find("iframe").contents();
iframe_node = jQuery(iframe_node.$)[0];
console.log(seciframecon.find('html').html());
// I get <head></head><body></body>
seciframecon.find('html').html(htmloutput);
console.log(seciframecon.find('html').html());
我得到我的字符串喜欢
<div class="ctools-modal-content> <div class="modal-header"> <span class="modal-title" id="modal-title" style="font-size:20px;">Format</span> <input value="format_facet" name="selectedfacet" type="hidden"> <a href="#" class="close"><img title="Close window" alt="Close window" src="xxxx" typeof="foaf:Image"> </a> </div> <div class="modal-content" id="modal-content" style="width: 475px; height: 355px;"> <table> <thead> <tr><th style="text-align:center;width:70px;">Include</th> <th style="text-align:center;width:70px;">Exclude</th> <th>Format</th> </tr> </thead> <tbody> <tr class="odd"> <td style="text-align:center;width:70px;"><div>balabalabala ....
这应该可以更改 iframe 内容,但它在火狐中不起作用!
html显示来自Firebug,如下所示。
<iframe style="z-index: 10030; position: absolute; left: 250px; top: 50px; width: 505px; height: 441px;">
<html>
<head>
</head>
<body>
</body>
</html>
HTML 已附加,然后很快在 Firefox 中消失
为什么console.log(seciframecon.find('html').html());
之后seciframecon.find('html').html(htmloutput);
可以得到字符串,但是 iframe 内容在 Firefox 浏览中仍然是空白的?
它在Chrome中运行良好。
有什么提示吗?
最后,我修复了它。原因是
当我尝试修改它时,iframe没有强制加载。
通过将负载绑定到这个 iframe dom,它可以在 Firefox 中工作。
jQuery(iframe_node.$).load('/topic-page/ajax/ckedialogpopup/' + selecttermfacet + '/' + filter, function(){
CKEDITOR.scriptLoader.load(
[
"/sites/all/themes/pharosui_omega/ckeditor/jsrender.min.js"
],
function() {
...
当我在研究这个问题时,我遇到了另一个问题jQuery .load(( 在 Chrome 中不起作用我通过将数据更新到 Web 服务器而不是从本地获取来修复它,导致 jQuery 加载函数不适用于本地(html/文本(数据。
希望这对其他人有所帮助。