DanH42 Posted January 17, 2010 Share Posted January 17, 2010 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. 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
Archived
This topic is now archived and is closed to further replies.