How can I send form data to test.html by using asynchronous communication?

前端 未结 1 1401
温柔的废话
温柔的废话 2020-12-22 10:07

I wanna send form data to test.html by using asynchronous communication. I wrote in index.html


   
&
相关标签:
1条回答
  • 2020-12-22 10:56

    If the document originates from same origin as original document and is opened by user action you can pass the parameters as a query string.

      document.querySelector("input[type=button]").onclick = e => {
        // pass key, value pairs to `test.html`
        const test = window.open(`test.html?${key}=${value}`, "_blank");
      }
    

    at opened window get and parse location.search

      onload = () => {
        // do stuff with key, value pairs passed from `window.opener`
        console.log([...new URLSearchParams(location.search).entries()])
      }
    

    plnkr http://plnkr.co/edit/MlCQZpkfBXFwxdR6gz5x?p=preview

    0 讨论(0)
提交回复
热议问题