码迷,mamicode.com
首页 > Web开发 > 详细

html5 xdm 页面之间的通信

时间:2016-11-12 18:57:24      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:get   function   ons   class   round   onload   asc   false   通信   

<!-- 这个是父页面xdm.html -->
<!
DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>XDM通信</title> </head> <body> <iframe id="iframeId" src="http://127.0.0.1:8020/avalon/iframe.html" width="100%" height="600px"></iframe> <script type="text/javascript"> window.addEventListener(load , function(){ var iframeWindow = document.getElementById(iframeId).contentWindow; iframeWindow.postMessage("滚犊子" , "http://127.0.0.1:8020/avalon/iframe.html"); }); </script> </body> </html>
<!-- 这个是子页面,iframe.html -->
<!
DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body onload="aaaa()"> <script type="text/javascript"> function aaaa(){ window.addEventListener(message , function(event){ console.log(event); alert(event.data); },false) } </script> </body> </html>

 

html5 xdm 页面之间的通信

标签:get   function   ons   class   round   onload   asc   false   通信   

原文地址:http://www.cnblogs.com/xudy/p/6057016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!