Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to access a popup's iframe parent 1

Status
Not open for further replies.

stevelionbird

Programmer
Jul 21, 2006
21
US
I'm trying to modify a js based html editor and what I need to do seems quite simple but I'm having trouble.

The editor loads in an iFrame, and the iFrame launches a popup window. Within the popup window, I need to determine the URL of the page that contains the iFrame.

I've tried
Code:
parent.document.URL
but that gives me the URL of the iFrame page .. so I guessed that
Code:
parent.parent.document.URL
might work but that yielded the same.

Is there a way from a popup window (which is opened by an iFrame) to determine the URL of the page that contains the said iFrame?

Thanks in advance,
Steve
 
Thanks Dan,

I was able to get the URL of the page I needed using the following:
Code:
alert(parent.opener.parent.location);
However this worked in Firefox but not IE..

Is there something syntactically wrong/non-standard with the above code, or at least another way to write it so that IE would recognize too?

Thanks again,
Steve
 
Ok I think I've identified the problem.

The HTML editor I'm using (FCKeditor) uses showModalDialog() to open the popup if it detects IE and after trying different variations of the window.opener syntax discussed above, it (opener) seems to be undefined every time in IE.

So, does anyone know if the popup generated using this showModalDialog() method is treated differently in the object model / how I could refer to it's opener .. assuming of course it is indeed different than the syntax posted previously?

many many thanks for any help on this!

Steve
 
I've figured it out...

opener is not defined for modalDialog, instead, I found what I needed nested in the window.dialogArguments object.

Thanks for your help Dan as what you posted will work in every other situation except for this special case with IE where showModalDialog() is used in place of window.open()

Best,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top