如何使用 jquery-ui 在另一个框架中弹出对话框 [英] How to popup a dialog in another frame using jquery-ui

查看:20
本文介绍了如何使用 jquery-ui 在另一个框架中弹出对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery-ui-1.8 创建一个小型网页,该网页具有一个框架集和三个框架.

I'm creating a small web page using jquery-ui-1.8 which is having a frameset and three frames.

<frameset id="mainFrame"cols="25%,*,25%"> 
    <frame  id="f1" src="test.php"></frame> 
    <frame id="f2" src="test2.php"/>
    <frame  />
</frameset>

然后我在 test.php 文件中添加了一个按钮,该文件在第一帧 (f1) 加载,并为 test2.php 添加了一个 div,它在第二帧加载.

Then I have added a button to test.php file which is loaded at the first frame (f1) and a div to test2.php which is loaded at the second frame.

<div id="testdiv"> this is test 2</div>

然后,当我单击 f1 中的按钮时,我需要在第二帧 (f2) 上的testdiv"中弹出一个 jquery 对话框.

Then I need to pop up a jquery dialog from "testdiv" on the second frame (f2) when I click on the button in the f1.

我尝试了这些线程中给出的解决方案.[1] - 在父窗口中显示jquery对话框

I tried following solutions given at these threads. [1] - Display jquery dialog in parent window

var $jParent = window.parent.jQuery.noConflict();
var dlg1 = $jParent('#testdiv');
dlg1.dialog();

和[2] - jQuery UI 对话框显示在框架内,来自书签?

var frame = window.frames[1];
var div = $(frame.document.getElementById("testdiv"));
div.html("My popup contents");
div.dialog();

但这些都不会在第二帧内弹出对话框.有人可以帮我解决这个问题.

But non of these pop ups the dialog within the second frame. Can some one please help me to solve this problem.

推荐答案

就这样做测试,也许这不是最好的方法,但你可以试试.(注意:不要忘记在iframe f2上添加属性-> name="f2" <-)

just make test for this way, maybe this is not the best way but you can try it. (Attention: don't forget to add the attribute -> name="f2" <- on iframe f2)

在test.php中:

in test.php:

<button onclick="parent.f2.$('#testdiv').dialog('open');">test</button>

<小时>

在 test2.php 中:


in test2.php:

<link type="text/css" href="jquery-ui.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
   $( "#testdiv" ).dialog({
    autoOpen: false
   });
});
</script>

<div id="testdiv"> hello world! </div>

这篇关于如何使用 jquery-ui 在另一个框架中弹出对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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