使用 window.opener.location 从安全 (https) 弹出窗口访问非安全 (http) 打开程序

发布于 2024-09-12 18:01:38 字数 360 浏览 4 评论 0原文

我正在从 http 下的网页打开 https 下的弹出窗口。当我尝试使用弹出窗口中的命令 window.opener.location.(href/str/port/domain.. 等) 来获取开启页面的 url 时,我收到“权限被拒绝”。我还在 Firefox 上使用 Firebug 来测试这一点。 有什么办法可以通过使用另一个命令或做其他事情来绕过这个问题。 如果我在 https 下打开 opener url,那么我就可以从弹出窗口访问它。我猜想这必须是在安全端口上而不是在非安全端口上。我认为这应该是可能的,因为我试图从安全页面获取非安全页面的信息。

基本上,我试图扫描打开页面的 url 并检查它是否包含某个子字符串,我想执行某个功能。任何实现这一目标的替代建议也将受到赞赏。

I am opening a popup which is under https from a web page which is under http. When I try to use the command window.opener.location.(href/str/port/domain.. etc) from the pop-up to get the url of the opener page, I get a 'Permission Denied'. Ive also been using Firebug on Firefox to test this out.
Is there any way I can by pass this by using another command or doing something else.
If I open the opener url under https, then I am able to access it from the pop-up. I am guessing this has to be with being on a secure port as compared to a non-secure one. I was thinking that this should be possible since I am trying to get the information of a non-secure page from a secure page.

Basically, I am trying to scan the url of the opener page and check if it contains a certain substring, I want to perform a certain function. Any alternative suggestions to achieving this would also be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ可否回来 2024-09-19 18:01:38

由于同源策略,您会看到错误。当两个域进行比较时,它会考虑协议、域名和端口。在您的情况下,协议不同,因此您会收到“权限被拒绝”异常。
您可以尝试以下技巧 - 当您打开弹出窗口时,将父级的 url 分配给弹出窗口 window.name,该窗口应该可用于弹出窗口内的 javascript。此外,您可以在末尾添加哈希值来构造弹出窗口的 url,例如:https://mydomain.com/page.html#http://mydomain.com/parent.html

您可以使用其他一些技巧来绕过 SOP

You see the error because of Same Origin Policy. When two domains compared it takes into consideration protocol, domain name and port. In your case protocols are different therefore you get "Permission denied" exception.
You may try the following trick - when you open the popup, assign parent's url to popup window.name, which should be available for the in-popup javascript. In addition you may construct url of your popup with hash at the end, for example: https://mydomain.com/page.html#http://mydomain.com/parent.html

There are couple other tricks you may perform to bypass SOP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文