Click to See Complete Forum and Search --> : Get complete external HTML source


saanesen
09-10-2004, 02:51 AM
I want to load the complete source of a html file into a variable so that I can collect some of the data and present it in my own way.

Earlier I used ActiveXObject("ADODB.Stream") to do this, but that doesn't work anymore because of a Microsoft Sequrity Update released earlier this year :(.

Anyone have another way of dealing with this? :confused:

Please advise.
Thanks

Kor
09-10-2004, 04:01 AM
Try a XMLHTTP solution, example:

<script type="text/javascript">
//<![CDATA[
function sendRequest(url)
{
var response = null;
var connection = new ActiveXObject("Microsoft.XMLHTTP");
try
{
connection.open("GET", url, false);
connection.send();
if(connection.readyState == 4) response = connection.responseText;
}
catch(e)
{
alert("ERROR: The remote host could not be found or the connection was refused.");
return false;
}
alert(response);
return false;
}
//]]>
</script>
...
...
<form action="#" onsubmit="return sendRequest(elements[0].value);">
<div>
<input type="text" style="width: 250px;" value="http://www.google.com/" />
<input type="submit" value="Send GET Request" />
</div>
</form>


It should work for Mozilla also, just replace new ActiveXObject("Microsoft.XMLHTTP") with new XMLHttpRequest()

saanesen
09-10-2004, 07:32 AM
Thank you Kor!
Works very well...