Re: How to load a webpage !!



"Evertjan." wrote:

karsagar...@xxxxxxxxx wrote:

I have a webpage ex.http://rss.cnn.com/rss/cnn_topstories.rss.  I
would like to access the associated XML file (which you get when you
do View -> Page source or Ctrl+U). Is there a way to do this using
javascript.

var http = new XMLHttpRequest(); // IE7 tested

That is not backwards compatible with IE5 and IE6 (still quite widely
used these days).

var http = null;
if (window.XMLHttpRequest) {
http = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
http = new ActiveXObject('Microsoft.XMLHTTP');
}

function getUrl(url) {
  http.open("GET",url,false);
  http.send();
  if (http.readyState == 4) {
    if (http.status == 200) {
        return http.responseText;
    };
  };

};

var s = getUrl('http://rss.cnn.com/rss/cnn_topstories.rss');
s = s.replace(/</g,'<br>&lt;');
document.write(s);

Microsoft Internet Explorer has the ugly habit to allow remote
XMLHttpRequest calls from the local filesystem; that's why this code
*appears* to work fine, while in reality - executed from a web server
- it doesn't.

The original poster might be interested in a cross-domain AJAX program
like e.g.
http://www.ajax-cross-domain.com
There are other possibilities, which basically make a web server/proxy
think that various resources belong to a same domain.

Cheers,

--
Bart
.



Relevant Pages

  • Re: create an http request from within a script
    ... I need to post an XML file to an external url. ... server is *not* configured as a web server, but does have http in the / ... open a socket to the HTTP server and format/send a HTTP POST ...
    (comp.unix.programmer)
  • [NEWS] Trend Micro InterScan VirusWall HTTP Proxy Content Scanning Circumvention
    ... Trend Micro InterScan VirusWall contains an HTTP proxy that prevents users ... from downloading virus-infected content by scanning the data received from ... a web server before passing it to the client. ... The Trend Micro InterScan VirusWall HTTP proxy contains a configuration ...
    (Securiteam)
  • RE: outlook and exchange
    ... Outlook using RPC over HTTP from the PC. ... Click To Do List and then click "Connect to the Internet". ... "Create a new Web server certificate", ...
    (microsoft.public.windows.server.sbs)
  • Re: Network Help
    ... > try to open an http: on the box, or on one of the other computers on ... > the network, it fails and has the network error: ... OR to not having any web server running on your box. ... 4- or..in a strange setup, you may have apache running from your inetd, ...
    (freebsd-questions)
  • Re: Network path name
    ... I apologize for wasting everyone's time with this issue. ... Or, if you are using http:, if the executable is in your default HTTP folder. ... without asking how the Web server finds the file. ... the program finds the configuration file OK. ...
    (microsoft.public.vc.mfc)