How to get the contents of a remote page using JavaScript?

I have the URL of a remote page from another domain that I have to download, parse and update the DOM of the current page. I found examples of this with the new ActiveXObject ("Msxml2.XMLHTTP") , but this, in my opinion, is limited to IE, and with the new java.net.URL , but I don't want to use Java. Are there any alternatives?

+5
source share
6 answers

The same domain rules will be available to you.

1) A proxy server through your server. browser-> your server-> their server-> your server-> browser.

2) . . javascript flash , . Silverlight , ...

3) . ... , javascript.

+3

PHP Script AJAX, file_get_contents()? . .

+2

script, , - . XMLHttpRequest, AJAX script, html (?) .

, . , , . ? , .

+1

, . iframes JS-, . "" () , .

- URL- .

.

0

Just use PHP:

<?php
$url = "http://www.domaintoretrieve.com";

ob_start();
include_once( $url );

$html = ob_get_contents();
ob_end_clean();

?>

$ html contains the entire page for management if necessary.

0
source

The XMLHTTPRequest object is common to most modern browsers and is a powerful AJAX web application.

-1
source

All Articles