how to retrieve the HTML source code using javascript?

Question by arun s: how to retrieve the HTML source code using javascript?
Please suggest a method by which i will be able to get the HTML source code using javascript

Thanks in Advance
Regards.

Best answer:

Answer by Mickey
Basicly

What do you think? Answer below!

No related content found.

Revisions

There are no revisions for this post.

Tags: , , , , ,

One Response to “how to retrieve the HTML source code using javascript?”

  1. Michael November 23, 2011 at 7:25 PM #

    You can get the source code for a page with javascript using document.URL to obtain the URL of the page, then set up a XMLHttpRequest to obtain the source code as in the following example:

    < !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >



    Get Source

    Get Source

    If javascript enabled, here is the source of this page:



    This will work in all modern browsers. You will need to search for XMLHttpRequest to find code to instantiate the XMLHttpRequest object in older browsers (if you need it to work in older browsers).

    For more on the script tag see http://www.html-tags-guide.com/html-script-tag.html

Leave a Reply