如何从弹出窗口获取网址? [英] How to get url from popup?

查看:73
本文介绍了如何从弹出窗口获取网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从打开的弹出窗口中获取URL.我已经尝试过 window.location.href .它不起作用.编写 console.log(window.location.href)时,将打印 unreadeable .如何从 React.js

I want to get url from opened popup. I tried already window.location.href. It is not working. When write console.log(window.location.href) there is unreadeable printed. How can I get url from popup in 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 "框架."

推荐答案

尝试一下

popupWindow.location.href newWindow.location.href

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

If the popup is from a third party, you will not be allowed to inspect the popup location.href

绕过同一来源政策的唯一方法是来自第三方的合作.

The only ways to bypass the same origin policy would involve cooperation from the third party.

这篇关于如何从弹出窗口获取网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆