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?

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

3 Comments

Any suggestions on a loophole for me?
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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.