javascript - accessing variable in parent page from iframe -


i have page iframe contains html page. want access javascript variable in parent page within iframe. name of variable in main page observer.

i have tried this

parent.observer = 'aadasds'; 

but getting following error:

permission denied property window.observer

.

exchanging values between iframes (and parent) allowed if both sites come same domain. if do, example should work. if don't, browsers inhibit communication.

however there number of hacks circumvent this: e.g yahoo.crossframe library described in julien le comte's blog using third iframe enable 1 way communication, or "resize iframe around iframe"-idea described in adam fortuna's blog enabling 2 way communication.

edit (as people still seem read old answer):
in modern browsers can use postmessage exchange data between iframes. there many javascript libraries try emulate functionality in older browsers, too. e.g. mis-using location.hash, jquery-postmessage-plugin does.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -