The IFRAME data sharing interface implemented by javascript:
passing data in an IFrame with a parent window or with a child window is a hassle, if we can write a once and for all interface that would be more convenient, here is a brief introduction to how to implement this function. the principle is to cache the data early window.top this window, so that no matter how the child window parent window hierarchy changes, the data will always exist unchanged.
The code is as follows:
varShare={data:function(name,value) {vartop=window.top, Cache=top[' _cache ']| |{}; top[' _cache ']=Cache; returnvalue?cache[name]=Value:cache[name]; }, Removedata:function(name) {varcache=window.top[' _cache ']; if(cache&&Cache[name]) { DeleteCache[name]; } } }; Share.data (' Mayi ', ' http://www.softwhy.com ');
The above code to achieve our requirements, the code is relatively simple, we can analyze it yourself, if you have any questions can be thread message.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=9141
For more information, refer to: http://www.softwhy.com/javascript/
The IFRAME data sharing interface implemented by JavaScript