我在模态对话框中有一个iframe。我可以通过单击Iframe中调用的字段内的按钮来关闭模态框吗?

时间:2012-04-02 10:44:06

标签: modal-dialog

I want to close both the i frame as well as the modal dialog box on a button click present inside the file which is called in the iframe.. the file included in the i frame is an external file having tabs.. So how to close the dialog box and iframe on a button click which is defined in the file..

我在网上搜了好几天但是没有解决问题......

//My Code for the iframe for and modal dialog box is as follows..


I want to close both the i frame as well as the modal dialog box on a button click present inside the file which is called in the iframe.. the file included in the i frame is an external file having tabs.. So how to close the dialog box and iframe on a button click which is defined in the file..

// here is the code for i frame

<div id="dialog_with_tabs" title="Vehicle Selection">// div of modal dialog
<div id="tabs_in_dialog">
<ul>
</ul>
<iframe id="myframe"  src="add.php" width="100%" height="400" frameborder="0" scrolling="auto" seamless="seamless">  /// here i have included a file which has tabs..
</iframe>  /*****************End of Iframe*********************/

</div>
</div>

/ ********************模态对话框的结尾******************* **** /      我想关闭i帧以及模式对话框,在iframe中调用的文件内的按钮单击时,i框架中包含的文件是带有标签的外部文件..所以如何关闭单击按钮上的对话框和iframe,在文件中定义..

//code for modal dialog box popup is as follows..

<script type="text/javascript" >           //script for modal dialog
$("#dialog_with_tabs").dialog({
bgiframe: true,
autoOpen: false,
height: 400,
width: 700,
modal: true,
buttons: {

}
});

$("#dialog_with_tabs").bind('dialogopen', function() {
/* init tabs, when dialog is opened */

$("#tabs_in_dialog").tabs();
});
$("#dialog_with_tabs").bind('dialogclose', function() {
/* your function */
window.location.reload(true);
/* destroy tabs to avoid problems on re-open */
$("#tabs_in_dialog").tabs('destroy');
/* destroy dialog to avoid problems on re-open */
$("#dialog_with_tabs").tabs('destroy');
});
/* your function to open the dialog */
$('#tabtest').click(function() {
$('#dialog_with_tabs').dialog('open');
}) 
//$("#dialog_with_tabs").dialog('open'); //  opens the modal dialog
<!-- jquery part -->
</script>

/ *********************脚本结束********************* /
    我想关闭i帧以及模式对话框,在iframe中调用的文件内的按钮单击时,i框架中包含的文件是带有标签的外部文件..所以如何关闭单击按钮上的对话框和iframe,在文件中定义..

// so how can close the dialog and iframe on a button click

任何帮助将不胜感激......

1 个答案:

答案 0 :(得分:0)

不确定如何准确地实现这一点,但我认为这条路线会起作用!

http://davidwalsh.name/window-postmessage

或者,试试这个帖子?

Pass jquery variables between iframe and parent