tags:

views:

48

answers:

3

I am trying to get the source page of a webpage on a different domain. I know this is easily done with PHP for example but I would like to do it in Javascript because I am getting results from a page and if I use a server-side language, the original website will block the calls since they come from the same IP. However, if the calls are done on the client side, it is like the user request the results each time (different user, different IP, no original site blocking me). Is there a way to do that (even if not in Javascript but client-side).

To clarify the code I want will be applied to an HTML page so I can get the results, style them, add/delete, etc then display them to the user.

Thank you.

A: 

On Windows you can use HTA

mplungjan
+3  A: 

Modern browsers support cross-domain AJAX calls but the target site has to allow them by using special headers in the reply. Apart from that, there is no pure Javascript solution AFAIK.

Tgr
A: 

Could you use an iframe? You wont have direct access to the markup to due to cross-domain restrictions, but you can still display the third-party page to the user...

window.onload = function() {
  var i = document.createElement("IFRAME");
  i.setAttribute("name", "ID_HERE");
  i.setAttribute("id", "ID_HERE");
  i.setAttribute("src", "URL_HERE");
  i.style.maxHeight = "300px";
  i.style.width = "100%";
  document.body.appendChild(i);
}
Josh Stodola
Well, not really since I only need part of the page returned not all of it. Is there an easy way to display part of the page only (the length and width might change depending on what's back. Is there a way to decide for example depending on an ID to display that part only?