load html-code into string

W

westonc

Axel said:
Is there a way in javascrip, to load the html-code of a webpage like
www.amazon.com
into a string? E.g.
string htmlcode = load_into_string( www.amazon.com);

I'm not sure how to get the code for the *entire* page, but loading the
page in a hidden iframe, and then grabbing document.body.innerHTML on
that frame would get you the html source of the body for that page...
 
E

Evertjan.

wrote on 23 sep 2006 in comp.lang.javascript:
I'm not sure how to get the code for the *entire* page, but loading the
page in a hidden iframe, and then grabbing document.body.innerHTML on
that frame would get you the html source of the body for that page...

Not with web security, if the page is from another server.

===========

Try [IE]:

<script type='text/javascript'>

var http = new ActiveXObject("Msxml2.XMLHTTP");

function getUrl(url) {
http.open("GET",url,false);
http.send();
return http.responseText;
}

htmlCode = getUrl('http://www.amazon.com')

alert(htmlCode)

</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top