1

This isn't a "how to" question at this stage, more of a "can I."

I am capturing form data on /page1.php - upon submit /page2.php is loaded which contains further form fields that are displayed via an iframe. The form that is loaded is hosted on another server (just in case that makes a difference).

The question I have is; Is there anyway of using javascript (or any other language) to autofill a field that is in the iframe?

I hope that makes sense but if anyone needs any clarification, please let me know.

thanks

6
  • stackoverflow.com/questions/1291812/… Commented Apr 28, 2014 at 19:14
  • 1
    "can I" - No :stackoverflow.com/questions/364952/… Commented Apr 28, 2014 at 19:15
  • @user574632 You reference a question that was asked/answered 5 years ago!! That's long time and surely new methods are available. Commented Apr 28, 2014 at 19:32
  • @JonathanRosenfeld Same origin policy has not changed. Why are you trying to do this - there is probably a better way, such as php cUrl Commented Apr 28, 2014 at 19:57
  • @user574632 onlineaspect.com/2010/01/15/backwards-compatible-postmessage - To answer your question, I'm trying to pre-populate the form fields in the iframe that are asking for the data I have already collected myself. Commented Apr 28, 2014 at 20:26

1 Answer 1

1

This part is important:

The form that is loaded is hosted on another server (just in case that makes a difference).

That makes a big difference, here's why:

"The same-origin policy restricts how a document or script loaded from one origin can interact with a resource from another origin." https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

You can try to use some Ajax to interact between the pages.

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

2 Comments

Thank you for the prompt reply. So you're not saying it's impossible, just not with javascript.
Dude, AJAX uses Javascript! :) But, yeah.. with pure Javascript, you can't achieve this without some unorthodox configuration.

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.