0

I would like to display the content of a particular div element on a 3rd party website on my website, using JavaScript. I know the id of the div element I want to display. Can this be done?

Hemantvc
  • 2,111
  • 3
  • 30
  • 42

3 Answers3

2

You can't do this with Javascript.

You have to download the page using a script on your server (using something like PHP), then use that downloaded data to look through its DOM, and then select the element you want.

Javascript only works on the current page showing in a browser, it can't (shouldn't) talk to other websites.

Ben
  • 54,723
  • 49
  • 178
  • 224
0

If you want to display a website in your own website then you can use iframe for that.

<div id="help"><iframe src="http://www.codeforbrowser.com" height="500px;width="600px;"></iframe></div>
defau1t
  • 10,593
  • 2
  • 35
  • 47
0

this could be possible though no trecomended:

you can load the external site into an iframe and then access the loaded frame specific element to get the value of the div you want and then putting it into your own div

Eyal Alsheich
  • 452
  • 4
  • 12