-1

Possible Duplicate:
Get DOM content of cross-domain iframe

I want to get know how I can get data from other websites/other domain name in javascript. I see many posts that's say it's impossible but I don't think it's impossible there is should some way that I am not able to find out! Is it possible to get data from Iframe or direct and set it to div and other element? Let me know. Note: Content/data are coming from another page. For example, my site is abc.com and gets data from xyz.com.

Community
  • 1
  • 1
Capripio
  • 474
  • 11
  • 21
  • Imagine if any site on the Web could open an iframe to `mail.google.com` and scrape the mail of any vistors who are logged in to Gmail. Tremendous security problem. – apsillers May 21 '12 at 18:49

3 Answers3

2

The reason people say it's impossible is because it's impossible.

It's impossible for a reason. Security.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • as I told you it's possible [take a Look this!](http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/) – Capripio May 22 '12 at 11:56
  • @Capripio: This uses Yahoo's YQL library, which fetches pages through a Yahoo proxy server. Yes, it works, but it is not a pure-javascript solution. Also, you will fetch pages as Yahoo sees them, e.g., not logged in. – apsillers May 22 '12 at 15:22
1

You'll need some server-side technology, like PHP, at the same domain as your JS downloading the content for you.

PHP proxy example: http://developer.yahoo.com/javascript/howto-proxy.html

Or you can configure a reverse proxy using mod_proxy on your Apache's httpd.conf. It's useful when you are working with APIs on a different domain:

ProxyPass /app/api http://other_domain:8080/api
ProxyPassReverse /app/api http://other_domain:8080/api
André Gil
  • 624
  • 7
  • 13
0

you can use e.g. php to get the link, and then proxy it from javascript.

Eric Fortis
  • 16,372
  • 6
  • 41
  • 62