postMessage 實現跨域消息傳遞 (JS)


簡單記錄一下 postMessage ,證明我來過, 我搞過(frame框架), 以后還能有個解決方法好去度娘:

1、發送消息

postMessage('test', 'http://localhost');

 

2、接收消息

    window.addEventListener('message', function (event) {
       console.log(event)
    }, false);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM