DanH42 Posted January 17, 2010 Share Posted January 17, 2010 (edited) I have an iframe that reloads periodically, and I need it to automatically scroll down to the bottom every time it updates. <script>function update(){ document.getElementById('text').src = 'log.txt';}setInterval(update, 10000);</script><iframe id="text" src="log.txt" frameborder=0 width="100%" height="100%"></iframe> I've tried a bunch of scripts, and none of them seem to work. Edited January 17, 2010 by DanH42 Link to comment Share on other sites More sharing options...
ApocalypeX Posted January 17, 2010 Share Posted January 17, 2010 If you change the text file to a html. Add an achor to where you want the iframe to show onload, then src="text.html#anchor" you should get what you want. Link to comment Share on other sites More sharing options...
just2comment Posted January 19, 2010 Share Posted January 19, 2010 Just in case you are still interested, I've found after many web sites and suggestions by Licho & Colorete:<html> <head> <!-- Thanks to Licho & Colorete --> <title>iframe content scrolled (finally...)</title> <script type="text/javascript"> function scrollDown() { var windowFrame = document.getElementById('text').contentWindow; var totalHeight = windowFrame.document.body.scrollHeight; windowFrame.scrollBy(0, totalHeight); } window.onload=function() { setInterval("document.getElementById('text').src = 'log.txt'", 5000); } </script> </head> <body> <iframe id="text" src="log.txt" frameborder=0 width="100%" height="100%" onload="scrollDown()"> </iframe> </body></html>I've tested this (a little bit) in IE, Mo & Op but you cannot take for sure it's cross-browser... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now