Is there an iFrame that reads .txt files AND Scrolls to the Bottom of the page?
I have a website on a Shared Server at work that I'm trying to get an iFrame to view the contents of a lengthy .txt file and I need it to AUTOMATICALLY scroll to the BOTTOM of the .txt file when the webpage opens.
I have a script that will scroll .htm files to the bottom but I can't get it to automatically Scroll a .txt file to the bottom (Best I've gotten is a button that you click which scrolls to the bottom) but I need it to Automatically do it when the page opens.
If it matters... My .txt file is actually a .LOG written in notepad with the 1st word ".LOG" which automatically inserts the Time & Date Each time the file is opened and it opens with the Cursor Automatically at the Bottom of the page.
If someone has a code that will scroll .txt files to the bottom, I'd Really Appreciate your help, Thanks!
I have a script that will scroll .htm files to the bottom but I can't get it to automatically Scroll a .txt file to the bottom (Best I've gotten is a button that you click which scrolls to the bottom) but I need it to Automatically do it when the page opens.
Can you show that script that scrolls an iframe containing a text file?
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
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:
Code:
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 Code:
<?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:
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,
That wasn't my experience. Attempting to access iframe.contentWindow threw an error.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
That wasn't my experience. Attempting to access iframe.contentWindow threw an error.
May I inquire what browser & version, plus how were you accessing the file? It does work for me from a server (just checked in IE 7, 8 & 9, Firefox 5, Safari 5 & Chrome 14) but from local file Chrome gives fits trying to access the document and does not work from local file.
I appreciate the information,
I’ve been dealing strictly with HTML and I've just recently started playing around with Javascripts that I’ve gotten off the internet and I don’t know anything about PHP. Anyway, I’ve just checked and my server does not support PHP but it does run Perl (Again I don’t know anything about Perl).
Can the Following be adjusted to allow the .LOG to Scroll to the Bottom?
<html>
<head>
<script type="text/javascript">
function scroll_to_end() {
var frame = window.frames.Log;
var doc = frame.document;
var node = doc.getElementsByTagName('body')[0].lastChild;
It was Stated above that ".LOG does work in Firefox 5 as an iframes src"
Our computers at Work are All defaulted for IE, However, we Do have Firefox 6 Installed on them. When people open this webpage Is there a way to get it to Open in Firefox and Not IE?
Bookmarks