Click to See Complete Forum and Search --> : How ro read a web page using Java Script


sanket
March 16th, 2002, 08:27 AM
Hi,
i would like to read athe contents of a webpage using java script.I would like to store the contents in a string & then work on this string.
How can this be done?
Thanks
Sanket Gupta

websmith99
September 27th, 2002, 01:19 AM
If your user base is IE4+ then this is simple using the
innerText or innerHTML properties:


<html>
<head>
<script language="JavaScript">

function readContent(){
// this is just the text on the page
contentsText = content.innerText;

// this also includes HTML tags as well as text
contentsAll = content.innerHTML;

alert(contentsText);
alert(contentsAll);
}

</script>
</head>
<body onLoad="readContent()">
<div id="content">
<table cellpadding="0" cellspacing="0">
<tr>
<td><b>Here is some content</b></td>
</tr>
</table>
</div>
</body>
</html>