5

Is it possible to load an html document into a DOM javascript object so that you can read the elements in the document? For example, if I have a file on the server Test.html. Can the page Hello.html call javascript code to load Test.html into a DOM object?

Please let me know.

Thanks

2 Answers 2

2

You can issue an AJAX request to the new page and get the result as HTML. Then you can bind the HTML to the DOM element.

If you can use a javascrpt library like jQuery there is a load method which loads the data from server and place the returned HTML in a DOM object.

See .load()

$('yourselector').load('Test.html', function() {
  alert('Load was performed.');
});
Sign up to request clarification or add additional context in comments.

Comments

1

Using jQuery:

$("#where_to_paste").load('Test.html');

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.