...

View Full Version : two questions regarding iframes



davidklonski
07-12-2004, 09:25 AM
Hi people

I got 2 questions regarding the usage of frames:
1) How can I calculate the exact top-left coordinate of an iframe which is located in the screen? The top-left coordinate needs to be in relation to the entire screen.
2) Consider the following: Page A opens a modal window B using window.showModalDialog(). Page B contains an IFrame C which is used to interact with the server.
When IFrame C reloads, I would like page B to close and page A to reload automaticaly.
I tried the following in C's body tag:


<body onload="parent.opener.location.reload(true); parent.close();">

page B gets closed with no problem but I get a JavaScript error on the first line saying: 'parent.opener.location' is null or not an object.

I would appreciate any help in any of the questions.
regards

glenngv
07-12-2004, 10:25 AM
You have to passed the window reference to the showModalDialog method.

window.showModalDialog('test.htm', window)

The dialog window now has the reference to the opener window by accessing the dialogArguments property.

in the dialog page (Page B):


function reloadParent(){
var win = window.dialogArguments;
win.location.reload(true);
window.close();
}

then in page C:


<body onload="parent.reloadParent();">

davidklonski
07-12-2004, 11:45 AM
As I said

The JavaScript code that has to run is in the context of the IFRame C and not thw window B.
thus if you write:


function reloadParent(){
var win = window.dialogArguments;
win.location.reload(true);
window.close();
}

Then window refers to the C IFrame which is wrong.

glenngv
07-12-2004, 12:06 PM
That function is in Page B so it runs in window B's context not in the calling iframe's.

davidklonski
07-12-2004, 02:08 PM
I managed to solve it by passing 'self' in the dialogArguments.

thanks for the help

okram
07-12-2004, 04:18 PM
<div style="position:absolute;left:70.2%;top:149;">
<iframe src="http://www.html" name="whatever" frameborder="0" noresize width="160" height="245">
</iframe>
</div>

glenngv
07-13-2004, 03:27 AM
I managed to solve it by passing 'self' in the dialogArguments.

thanks for the help

window is synonymous to self, so I don't know why window didn't work for you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum