Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html
[Netscape 4 or better]
<HTML>
<HEAD>
<SCRIPT LANGUAGE= "JavaScript1.2">
function getPage() {
// the file to be read
pageURL = new
java.net.URL
("http://www.yourserver.com/yoyrpage.html");
// step 1, open the URL
var openConnection = pageURL.openConnection;
theConnection = openConnection()
// step 2, connect to server
var t=theConnection.connect
t()
// step 3, read the file using HTTP protocol
var getContent = theConnection.getContent
var theURLStream = getContent()
// step 4, get an handle and fetch the content length
var readStream = theURLStream.read
var gcl = theConnection.getContentLength
gcLen = gcl()
// and finally, read into a variable
theText =""
for (i = 1; i <gcLen; i++) {
theText += new java.lang.Character(readStream())
}
// for demonstration
alert(theText)
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="button" VALUE="get page" onClick="getPage();">
</FORM>
</BODY>
</HTML>
After pressing the button, wait a few seconds while the page is read, then an Alert box containing the page content will appear, if the Alert box is bigger (probably) than the screen, just press ENTER to close it.
Posted On: 10-Jul-1999