[英]Getting the URL of an iFrame cross domain and protocol in jQuery
I am basically creating an external shopping cart system for users on my site that will lead to a secure system that I am paying for, and in their shopping pages, they auto-generate a PHP GET variable called CFTOKEN
that I need to access so I can send cart updates. 我基本上是在为网站上的用户创建一个外部购物车系统,该系统将导致我要付费的安全系统,并且在他们的购物页面中,他们会自动生成一个我需要访问的名为
CFTOKEN
的PHP GET变量,因此可以发送购物车更新。
I am loading an iframe with the URL that redirects to the shopping cart with the CFTOKEN
variable in the URL. 我正在使用URL加载iframe,该URL使用URL中的
CFTOKEN
变量重定向到购物车。 I need to get this variable in javascript so I can send updates to the cart. 我需要在javascript中获取此变量,以便可以将更新发送到购物车。
I have tried accessing the URL by the following code: 我尝试通过以下代码访问URL:
$("#iframe").contents().get(0).location.href
but I not only get a cross domain error, I get undefined
for the location. 但是我不仅遇到跨域错误,而且位置
undefined
。
How can I get the URL? 如何获取网址?
You simply can't in modern browsers, it would've been a security issue. 您根本无法在现代浏览器中使用,这已经是一个安全问题。 I'm sorry.
对不起。
You can read more about it here: How do I get the current location of an iframe? 您可以在此处了解更多信息: 如何获取iframe的当前位置?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.