標籤: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 頁面之間的通訊