So, in facebook, I cannot call myFrame.window to get the iframe parent window. How can I do it?
What I'm trying archieve is: I have a popup (div) that will load a iframe.
And then in the iframe will have a button. Once people click the button inside the iframe, I want to close the popup(div). Normally, I need to get the parent window. Then I can destroy the popup div. But in facebook, how can I do it? any alternative way to d开发者_如何学Pythono that?I don't want to refresh the page. :)
If you can't access the parent from the iframe, you could try sending a function reference from the parent to the iframe.
In your parent:
iframe.contentWindow.closeFn = function() { /* destroy popup */ }
Then, in your iframe, call window.closeFn()
when you want to destroy the popup.
The contentWindow
may have some cross-browser issues, you can read further here
I have not tried this in Facebook myself - no guarantees it will work there, but might be worth trying.
精彩评论