如何从弹出窗口获取网址?

IT技术 javascript reactjs
2021-05-19 23:20:32

我想从打开的弹出窗口中获取 url。我已经试过了window.location.href它不工作。当写console.log(window.location.href)unreadeable打印。我如何url从弹出窗口中获取React.js

var newWindow = window.open("http://www.google.com/", "Code",
     'scrollbars=yes, width=' + 800 + ', height=' + 640 + ', top=' + top + ', left=' + left);

错误是

""react-dom.development.js:289 未捕获的 DOMException: 阻止了一个源为 " http://localhost:3000 " 的框架访问跨源框架。""

2个回答

试试这个

popupWindow.location.href 或者 newWindow.location.href

如果弹出窗口来自第三方,则不允许您检查弹出窗口 location.href

绕过同源政策的唯一方法将涉及第三方的合作。

// basic XSS Payloads

javascript:alert(document.domain);

"><script>alert(document.domain);

//or

document.getElementById("demo").innerHTML =
"Page location is " + window.location.href;