将iframe内部的jquery对话框定位到父窗口 [英] positioning a jquery dialog that is inside an iframe realtive to the parent window

查看:111
本文介绍了将iframe内部的jquery对话框定位到父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有

我有一个网站上有一个非常大的滚动,并且在
中间有一个iframe没有滚动并且它的高度是3000

i have a site which has a very big scroll on it, and there is an iframe in the middle set to have no scroll and its height is 3000

无论如何,在iframe中打开的文档中都有一个jquery对话框。

anyway the document being opened in the iframe has a jquery dialog in it.

当我查看父
的顶部并单击iframe中的按钮打开对话框
时,对话框在iframe的中间打开,我看不到...

when im looking at the top of the parent and click a button inside the iframe that opens the dialog the dialog opens at the middle of the iframe and i cant see it...

这是因为它根据文件而不是顶级文件进行计算

thats because its doing its calcualtions based on the document not the top document

我该怎么改变呢?

所以如果我的滚动在父母中一直向下,iframe中的对话框将在iframe的底部打开,我可以看到它...换句话说,实际上是父母的位置文件。

so if my scroll was all the way down in the parent the dialog inside the iframe will open at the bottom of the iframe where i can see it.. in other words realtive to positon of parent document.

这是我打开对话框的方式:

this is how i open my dialog:

generalDialog.dialog({
   bgiframe:false, height:p_height, width:480, modal:true, autoOpen:false, hide:'fadeout', show:'slide', closeOnEscape:true}); generalDialog.dialog("open");

提前感谢

推荐答案

我让它工作了!

这是你需要在jquery对话框插件中更改的内容
这是一个非常好的改变,因为它使对话框从iframe和常规页面起作用

this is what you need to change in the jquery dialog plugin its a very good change because it makes the dialog work from an iframe as well as just a regular page

(只有当你在同一个域时才会起作用)

(this will only work if you are on the same domain )

这是您需要更改的行:

这一行:

pTop = doc.scrollTop()

到此:

pTop = $(top.document).find("html").scrollTop()

和这一个:

pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2;

到此:

pTop += ($(top.document).find("html").attr("clientHeight") - this.uiDialog.outerHeight()) / 2;       

修复它。

这篇关于将iframe内部的jquery对话框定位到父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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