That code is not capable of scrolling an iframe containing a pure text file, it has to be HTML
True, only because that code attempts to obtain the offsetHeight of an element with id of 'lorem' which is presumed to be in the iframes document:
num=obj.contentWindow.document.getElementById('lorem').offsetHeight;
Now, if you happen to set the src of an iframe to a .txt file, the browser injects html tags in to the iframe with the contents of the .txt file contained in a <pre> element, such as:
<html><head></head><body><pre>**plus the contents of the .txt file here without these stupid asterisks**</pre></body></html>
So then if you are using a .txt file as the iframes src, you would change the definition of the variable "num" above to:
num = obj.contentWindow.document.getElementsByTagName('pre')[0].offsetHeight;
Now, are you actually wanting to use the .LOG file instead of .txt file? If so, IE throws a wrench in the handling of them, at least IE less than v9.0, will think the file should be downloaded by user manually. In IE 9 it's fine though. Not sure about other browsers, but .LOG does work in Firefox 5 as an iframes src. But probably best, if you do wish to use the .LOG file, is to relay it through a .php page if you have php installed on server. This would more or less "unify" the handling between different browsers. The php page would be simple:
<?php
//>getLog.php
$filename = 'log.LOG';//edit name of .LOG file appropriately
echo '<pre>';
print_r(file_get_contents($filename));
echo '</pre>';
?>
And then the html page containing the iframe and the script to scroll it, try changing the iframes src to the name of your .LOG file if you wish, it will work in the latest browsers only, which may not be an issue for you if this is a local app for your intranet only and have control over what browser is used, else I would recommend the .php file:
<html>
<head>
<title>some title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#container {
width:600px;
height:260px;
border:3px double #999;
margin:0 auto;
}
#myiframe {
width:100%;
height:100%;
}
</style>
<script type="text/javascript">
window.onload = function() {
var obj = document.getElementById('myiframe');
var pre0 = obj.contentWindow.document.getElementsByTagName('pre')[0];
obj.contentWindow.scrollTo(0, pre0.offsetHeight);
};
</script>
</head>
<body>
<div id="container">
<iframe src="getLog.php" id="myiframe" frameborder="0"></iframe>
</div>
</body>
</html>