I am attempting to create a login button for web application which either loads an iFrame or a pop up window. Similar to that of Facebook login button. Im currently using the postMessage() method which works a treat.
However I know that it wont work in IE6/IE7 which I need to support. Is their any alternatives I could possibly use? or am I hoping for to much from the "awesome browser" that is IE6?
Back in the day, I used to write IE6-based websites that opened popups and communicated between the popup and the original window.
So it can be done.
The browser provides a few objects you can use for this -- window.caller
is the one you'll most likely want for passing calls back from the opened window to the original one, in addition to the object returned by the window.open()
call, which you can use to pass calls from the original window back to the new one.
These two together will allow you to communicate in both directions.
You might also have some joy with jQuery, as I believe there are several plugins that wrap these methods in more friendly interfaces.
However, be aware that what you can do is a lot more limited in these older browsers than what's possible now, so even though you will be able to do to cross-window comms, you may find there are things you need that can't be done in older browsers.
Hope that helps.
来源:https://stackoverflow.com/questions/11121435/postmessage-alternative-for-ie6-7-between-iframes-and-or-pop-ups