• postMessage跨域传参


    http://127.0.0.1:8888/A.html

    1. <script>
    2. $(function(){
    3. const result = window.open('http://127.0.0.1:9999/B.html')
    4. if (result) {
    5. const param = {
    6. type: 'customParam',
    7. param: '123456'
    8. }
    9. setTimeout(() => {
    10. result.postMessage(param, 'http://127.0.0.1:9999/B.html')
    11. console.log('已发送')
    12. }, 500)
    13. }
    14. })