• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening a url and reading the HTML content

 
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone suggest me how one should open a url and read its HTML using javascript.

I have done using VBScript using I would like to know how we do this in JavaScript..

Thanks in advance,
Muthu
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XMLHttpRequest

Only works on same domain, if you need to do another domain, you need to use a proxy on the server and read hat via Ajax.

Eric
 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric,
May I know how can we accomplish that within a domain
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XMLHttpRequest tutorial

 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric,
I am used to AJAX using jQuery..

I was wondering if this can be done only using JavaScript at the Client side without the server's interference, as it is possible with VBScript, it must also be possible with javascript, if I am not wrong..
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "without the server's interference"? Surely the server needs to serve the file? If you're talking about a client-side file, then there's no way to do that using JavaScript and/or XMLHttpRequest. VBScript can do it only because it creates a native ActiveX control that lives outside of the browser sandbox.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to read some other domain without a proxy, than you would need a server. IE8 and FF3.5 can read other domains, but that requires control of both domains.

If you are doing it on the same domain, there is no need for a serverside proxy.

If you want a local file, it is not going to happen.

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic