JQuery的 - 如何追加对象基于WebKit的浏览器(铬/ Safari浏览器)设置为iFrame? [英] JQuery - how to append object to iframe in WebKit based browsers (chrome/safari)?
问题描述
我有这样的code:
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
$(#iframeId)的内容()找到(身体)追加($(#测试))。;
});
< / SCRIPT>
< IFRAME ID =iframeIdNAME =iframeIdSRC =有关:空白>< / IFRAME>
< DIV ID =测试>
文本
< / DIV>
,我需要整个对象追加到IFRAME(不仅是HTML())。
它运作良好,在IE,Firefox和Opera,但我不能让它打算在Chrome / Safari浏览器。是否有任何黑客或其他方式,如何把HTML对象进入的iframe,与WebKit的工作吗?
修改
我不能克隆对象(或使用其内部HTML),因为我需要用文件输入使用它,我无法将其复制由于安全限制。
outerHTML 。这个例子正常工作:
jQuery.fn.outerHTML =功能(){
返回$('&所述; DIV>')附加(this.eq(0).clone())的.html();
};。$(#iframeId)的内容()找到(身体)HTML($(#测试)outerHTML()。)。
$(#测试),删除()。
- 编辑
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
$(#iframeId)的内容()找到(身体)HTML($(< DIV>< / DIV>中。)追加($(#测试))HTML() );
});
< / SCRIPT>
< IFRAME ID =iframeIdNAME =iframeIdSRC =有关:空白>< / IFRAME>
< DIV ID =测试>
文本
< / DIV>
- 编辑II
<$p$p><$c$c>$(\"#iframeLast\").contents().find(\"body\").append($(\"<form></form>\").append($(\"#inputLast\")));I have this code:
<script type="text/javascript">
$(document).ready(function() {
$("#iframeId").contents().find("body").append($("#test"));
});
</script>
<iframe id="iframeId" name="iframeId" src="about:blank" ></iframe>
<div id="test">
Text
</div>
And i need to append whole object to iframe (not only the html()). It works well in IE, Firefox and Opera, but I can't make it going in Chrome/Safari. Is there any hack or other way, how to put html object into the iframe, working with WebKit?
EDIT
I can't clone the object (or use its inner Html), because I need to use it with file input and I can't copy it due to security restrictions.
outerHTML. This example works fine:
jQuery.fn.outerHTML = function() {
return $('<div>').append( this.eq(0).clone() ).html();
};
$("#iframeId").contents().find("body").html($("#test").outerHTML());
$("#test").remove();
--EDIT
<script type="text/javascript">
$(document).ready(function() {
$("#iframeId").contents().find("body").html($("<div></div>").append($("#test")).html());
});
</script>
<iframe id="iframeId" name="iframeId" src="about:blank" ></iframe>
<div id="test">
Text
</div>
--EDIT II
$("#iframeLast").contents().find("body").append($("<form></form>").append($("#inputLast")));
这篇关于JQuery的 - 如何追加对象基于WebKit的浏览器(铬/ Safari浏览器)设置为iFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!