Positioning jquery dialog which is inside iframe realtive in parent window
hallo all
I have a site that has a very large scroll and has an iframe in the middle you have no scroll and its height is 3000
anyway document opened in iframe has jquery dialog in it.
when i look at the top of the parent and click the button inside the iframe that opens the dialog the dialog opens in the middle of the iframe and i dont see it ...
thats because its doing calculations based on the document not the top document
how can i change this?
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 the parent document.
this is how i open the dialog:
generalDialog.dialog({
bgiframe:false, height:p_height, width:480, modal:true, autoOpen:false, hide:'fadeout', show:'slide', closeOnEscape:true}); generalDialog.dialog("open");
early
a source to share
I got it to work!
this is what you need to change in the jquery dialog plugin this is a very good change because it makes the dialog work with an iframe as well as a normal page
(this will only work if you are on the same domain)
these are the lines that need to be changed:
this:
pTop = doc.scrollTop()
:
pTop = $(top.document).find("html").scrollTop()
and this one:
pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2;
:
pTop += ($(top.document).find("html").attr("clientHeight") - this.uiDialog.outerHeight()) / 2;
which fixes it.
a source to share
you must use self.parent to refer to the document object that your iframe is contained in when doing calculations, otherwise the calculations are based on the document object inside the iframe. This is what currently causes your dialog to be in the center of the document object in the iframe, not in the document object of the parent page containing the iframe. hope that makes sense :)
a source to share