0

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

2 Answers 2

1

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);
});
Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Can you give me link to more detailed document for above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.