如何在单击事件上从iframe打开jquery ui对话框 [英] How to open a jquery ui dialog box from an iframe on a click event

查看:73
本文介绍了如何在单击事件上从iframe打开jquery ui对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从iframe打开一个jquery ui对话框。当单击按钮打开对话框时,对话框假设在iframe上显示为bootstrap模式。



我遇到的问题是当我单击一个按钮打开对话框,打开对话框中其他文件的整个页面。



我尝试了什么:



myIframeFile.asp:



< iframe id =myiframesrc =myFileToOpenTheDialogBox.asp ?a =<%= Request.QueryString(a)%>>< / iframe>





myFileToOpenTheDialogBox.asp:





< button id =btnOptions>选项< / button>



< div id =dialogtitle =Optionsstyle =display:none;>

< form>

...

< / form>

< / div>



< script> ;



I am trying to open a jquery ui dialog box from an iframe. When the button is clicked to open the dialog box, the dialog box is suppose to display over the iframe like a bootstrap modal.

The problem I am having is when I click a button to open the dialog box it opens the entire page of the other file inside the dialog box.

What I have tried:

myIframeFile.asp:

<iframe id="myiframe" src="myFileToOpenTheDialogBox.asp?a=<%=Request.QueryString("a")%>"></iframe>


myFileToOpenTheDialogBox.asp:


<button id="btnOptions">Options</button>

<div id="dialog" title="Options" style="display:none;">
<form>
...
</form>
</div>

<script>

$(document).ready(function(){
      $("#btnOptions").click(function(){
         $("#myiframe", window.parent.document).dialog({
            width:800,
            resizable: true
         });
      });
    });



< / script>


</script>

推荐答案

document )。ready( function (){
(document).ready(function(){


#btnOptions)。click( function (){
("#btnOptions").click(function(){


#myiframe window .parent。 document )。dialog({
width: 800
可调整大小: true
});
});
});
("#myiframe", window.parent.document).dialog({ width:800, resizable: true }); }); });



< / script>


</script>


这篇关于如何在单击事件上从iframe打开jquery ui对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆