iframe可經過postMessage解決跨域、跨窗口消息傳遞

http://www.javashuo.com/article/p-uyfsofag-dg.htmljavascript

跨域微信分享https://blog.csdn.net/hsdllcw/article/details/79326189html

1 //iframe傳參給父級頁面
2 function give_info(){
3     console.log("觸發事件");
4     window.parent.postMessage(1,'*');
5 }
//接收值window.addEventListener('message',function(e){
            var color=e.data;
            document.getElementById('color').style.backgroundColor=color;
},false);
相關文章
相關標籤/搜索