0

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.

I am loading an iframe with the URL that redirects to the shopping cart with the CFTOKEN variable in the URL. I need to get this variable in javascript so I can send updates to the cart.

I have tried accessing the URL by the following code:

$("#iframe").contents().get(0).location.href

but I not only get a cross domain error, I get undefined for the location.

How can I get the URL?

Liftoff
  • 24,717
  • 13
  • 66
  • 119

1 Answers1

1

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?

Community
  • 1
  • 1
Karl Laurentius Roos
  • 4,360
  • 1
  • 33
  • 42
  • Any suggestions on a loophole for me? – Liftoff Apr 27 '13 at 00:09
  • So basically what you want is that the main application wants access to `CFTOKEN` which is a value used for authenticating and updating the cart. Do you have control over the cart or is it a separate system? Could you write some sort of method there for fetching it based upon the same user input as it's created? – Karl Laurentius Roos Apr 27 '13 at 07:58
  • I have no access to any of the cart functions, etc. All I need is that one variable. That variable is also embedded in the source code of the page, if there's any way I could get it that way. – Liftoff Apr 27 '13 at 19:40