更新时间:2023-11-27 15:00:28
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()])
}