Tuesday, May 3, 2011

Read html file in variable through javascript in unix (firefox)

OS: Linux Browser : Firefox

I need to read a html file content into a string variable through JavaScript ?

Is it possible in javascript ? If yes, Kindly help me with syntax/method to do this

From stackoverflow
  • The easiest solution is probably to use the JQuery library.

    http://docs.jquery.com/Ajax/jQuery.get

    $.get("mypage.html", function(data){
      alert("Data Loaded: " + data);
    });
    
  • I think that this should do the trick. It's untested but give it a try.

    document.documentElement.innerHTML
    

    Another approach could be to query the URL through XmlHttpRequest and read the response.responseText

0 comments:

Post a Comment