Jump to content

Autoscroll An Iframe


DanH42
 Share

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.

Edited by DanH42
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...