Access Denied when I access parent window for the second time
I want to display a html form in browser, this html contains an iframe. In Iframe, there is a link to launch a popup. In the popup html, there are two links. Click each link should display a html file in the base browser (at the top level).
Any idea why this happens and how to achieve this?
I am attaching all the html files in "iframe-error.zip". The base html is "base.html".
I appreciate your help!
In your popup window, are you using window.opener to access the original window? ...or, what?
I am using window.opener.parent to access the original window
I am using window.opener.parent to access the original window.
If I click the link in popup window at first time, it works fine, but from the second time, it displayed the 'Access Denied' error message.
OK, yes, the IFRAME is a window object. When you replace the parent document, you destroy that window object. Thus, the window.opener reference in the popup window is no longer valid.
so is there any alternatives to achieve this?
I want to keep the popup open all the time, and click different links in the popup to show different pages in the base browser.
Is it even doable if IFRAME is involved?
Well, each document that you load into the main window is going to have to re-establish the connection with the popup window. This can be accomplished by using the same window.open() specification for the window name that was used when the popup was first create. So, if the following was used the first time:
window.open('...someURL...', 'MyWindow', '...optional features...');
then the following is what you want to do from the new document when it loads into the main window:
As strange as it may seem, using a zero-length string for the URL and giving a matching window name will re-create a pointer to that popup window. Then you can refresh the window.opener reference as shown above.
winPtr = window.open('', 'MyWindow', '...optional features...');
winPtr.opener = self;
Mind you, this means that you can't be using window.opener.parent.location... anymore. I recommend you change that to window.opener.top.location... as this will be a consistent reference to the topmost window in the browser no matter which way the window.opener reference is currently set.
Last edited by phpnovice; 04-07-2005 at 02:45 PM.
thanks a lot...
Thanks a lot. I will try it out on my machine and see if it work.
I really appreciate your help!
it works perfect. Looks like passing blank URL with the same popup name does re-establish the connection between the base window and the popup window
Thanks a lot.
Was there any doubt?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)