Jump to content

Autoscroll An Iframe


DanH42

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...