使用javascript获取弹出窗口的当前url [英] Get current url of the popup window with javascript

查看:398
本文介绍了使用javascript获取弹出窗口的当前url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有链接的网页,它会在弹出窗口中打开一个新页面。
一切都很好,直到这里,弹出窗口包含一些第三方服务器持有的信用卡支付页面。完成付款流程后,会显示回复,并且网址会有变化。

I had a webpage with a link, which opens a new page in a popup window. Everything is fine till here, The popup window contains credit card payment page held by some 3rd party server. After completing the payment flow the response is shown and there is change in the url.

我需要获取该网址。

是否可以在javascript中使用?

Is it is possible in javascript?

推荐答案

页面的URL可通过位置属性。如果您正在访问与您相同的子域名中的站点,那么您可以通过

The URL of a page is accessible through the location property of the window object. If you are visiting a site on the same subdomain as you , then you can get the address via

popupWindow.location.href

但是,如果弹出窗口来自第三方,同一源策略适用,您不能检查弹出窗口的location.href。绕过同一原产地政策的唯一方法是涉及第三方的合作。

However, if the popup is from a third party, the same origin policy applies and you are not allowed to inspect the location.href of the popup. The only ways to bypass the same origin policy would involve cooperation from the third party.

这篇关于使用javascript获取弹出窗口的当前url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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