0

I have a form on website 2 that I need to populate with data on website 1. The code I have so far is:

function fillOutForm () {
document.getElementById('input1').value="innerHTMLFromWebsite2";
}

How do I import the HTML from website 2 and insert it into the "innerHTMLFromWebsite2" section of the above code?

Also to note the 2 websites are on different domains. Think website1 is www.mycompany.com and website2 is www.tripadvisor.com.

Thanks in advance!

Alex Klinghoffer
  • 349
  • 4
  • 7
  • 15
  • you can open url in iframe and then you can get complete html by javascript: document.getElementById('iframe').contentWindow.document.body.innerHTML – Manish Shukla Apr 15 '15 at 18:34

1 Answers1

0

You cannot do that because of the same-origin policy http://en.wikipedia.org/wiki/Same-origin_policy

You can disable that policy if you are the administrator of website2, also check this other question.

How to make cross domain request

Community
  • 1
  • 1
NPV
  • 41
  • 4