如何在Iframe中重新加载附加数据


how to reload appended data in an Iframe

使用JQuery在iframe中添加了一些数据后,我需要重新加载添加的数据。数据中包含一些脚本标签。

这是我附加到iframe的代码示例。div将出现在iframe中,但脚本不起作用。出现了我添加的警告,但由于某种原因,JQuery代码不会将div转换为对话框。我说也许是因为我应该重新加载这个iframe中附加的数据。这可能吗?

<style>
   .draggable { width: 90px; height: 80px; padding: 5px; float: left; margin: 0 10px 10px 0; font-size: .9em; }
   .ui-widget-header p, .ui-widget-content p { margin: 0; }
   #snaptarget { height: 140px; }
</style>
<script type="text/javascript">
   $(function() {
     window.alert("TEST dialog1");
     $( "#dialog1" ).dialog({ title: "Notifications Widget" });
     $( "#dialog1" ).dialog( "option", "position", [200,200] );
     $( "#dialog1" ).dialog().parents(".ui-dialog").draggable("option", "snap", true);
   });
</script>
<div id="dialog1" class="draggable ui-widget-content">
   <p>I am a notification widget</p>
</div>

thanks for help

显示了我添加的警告,但由于某种原因,JQuery代码不会将div转换为对话框

出现

警报,因此您的脚本实际上已经添加并且工作正常。请记住,你必须有jQuery, jQuery UI, css或任何其他所需的代码,以正确地工作在iFrame内链接就像。它不能直接访问父窗口代码。你可以把它想象成另一个浏览器选项卡/窗口。