来自iframe的jquery-ui-dialog超过父文档

时间:2023-01-23 19:46:35

i have few previously built pages that use jquery-ui-dialog and works fine. now my requirement was to make a page with a iframe in it. and this iframe is used to display those previously created pages. in this case the dialogs from the iframe appears inside the iframe not over the parent document. how can i make the dialogs appear over the parent document containing the iframe with minimum change?

我之前构建的页面很少使用jquery-ui-dialog并且工作正常。现在我的要求是制作一个包含iframe的页面。并且此iframe用于显示先前创建的页面。在这种情况下,iframe中的对话框显示在iframe内部而不是父文档上。如何让对话框显示在包含iframe的父文档上,且变化最小?

thanks in advance.

提前致谢。

2 个解决方案

#1


1  

If your pages are on the same domain, you could call a function in the parent document from the iframe to display the dialog.

如果您的页面位于同一个域中,则可以从iframe调用父文档中的函数以显示该对话框。

For example...

例如...

parent.ShowDialog("Hello World");

With a function in the parent that opens up the UI dialog using the supplied text.

使用父级中的函数,使用提供的文本打开UI对话框。

#2


1  

Ugh, iframes always seem to cause problems... best to avoid them completely (I understand if this probably wasn't your choice).

呃,iframe似乎总是会引起问题......最好完全避免它们(我明白这可能不是你的选择)。

The problem is the browser interprets the i-frame as a separate web page. Not sure, but you could try to define your dialog element (the HTML tags) outside the i-frame and try calling the event from the inside. Something like:

问题是浏览器将i帧解释为单独的网页。不确定,但你可以尝试在i-frame之外定义你的对话框元素(HTML标签),并尝试从内部调用事件。就像是:

<html>
<div id="callme" style="display:none;">
...
your dialogstuff here
...
</div>

<iframe>
<!-- function that calls the dialog event here -->
</iframe>
</html>

It's worth a shot, I guess.

我想这值得一试。

#1


1  

If your pages are on the same domain, you could call a function in the parent document from the iframe to display the dialog.

如果您的页面位于同一个域中,则可以从iframe调用父文档中的函数以显示该对话框。

For example...

例如...

parent.ShowDialog("Hello World");

With a function in the parent that opens up the UI dialog using the supplied text.

使用父级中的函数,使用提供的文本打开UI对话框。

#2


1  

Ugh, iframes always seem to cause problems... best to avoid them completely (I understand if this probably wasn't your choice).

呃,iframe似乎总是会引起问题......最好完全避免它们(我明白这可能不是你的选择)。

The problem is the browser interprets the i-frame as a separate web page. Not sure, but you could try to define your dialog element (the HTML tags) outside the i-frame and try calling the event from the inside. Something like:

问题是浏览器将i帧解释为单独的网页。不确定,但你可以尝试在i-frame之外定义你的对话框元素(HTML标签),并尝试从内部调用事件。就像是:

<html>
<div id="callme" style="display:none;">
...
your dialogstuff here
...
</div>

<iframe>
<!-- function that calls the dialog event here -->
</iframe>
</html>

It's worth a shot, I guess.

我想这值得一试。