简体   繁体   中英

Auto scroll down a textarea after refreshing a page

I have a script that shows a log of a program, I've tried to add header("refresh: 5;url=wget_log.php#bottomOfPage"); but it still won't scroll down to the bottom of the textarea. Here's my script:

<?php
header("refresh: 5;url=wget_log.php#bottomOfPage");
include 'theme.php';
ceklogin();
css();
echo " Wget log :<br>";
echo "<textarea name=\"bottomOfPage\" rows=\"30\" cols=\"90\" readonly style=\"font-family: Arial;font-size: 7pt;\" >";
$datalines = file ("wget.log");
foreach ($datalines as $zz) {
echo $zz; }
echo "</textarea></div>";
foot();
echo '

</div>
</body>
</div>
</html>';
?>

Here's the webpage looks like, sorry I'm still not allowed to show images directly on stackoverflow so I'm just gonna give you the link to the image: http://s22.postimg.org/cgap9i8kh/image.jpg

@ Magictallguy I modified my script to be like this:

<?php
header("refresh: 5;url=wget_log.php#bottomOfPage");
include 'theme.php';
ceklogin();
css();
echo " Wget log :<br>";
echo "<textarea name=\"text-info\" rows=\"30\" cols=\"90\" readonly style=\"font-family: Arial;font-size: 7pt;\" >";
$datalines = file ("wget.log");
foreach ($datalines as $zz) {
echo $zz; }
echo "<span id=\"bottomOfPage\">&nbsp;</span>"
echo "</textarea></div>";
foot();
echo '

</div>
</body>
</div>
</html>';
?>

but it still won't scroll down.

You need to add id="bottomOfPage" somewhere at the bottom of the page

Or, more precisely, add <span id='bottomOfPage'>&nbsp;</span> just before your </textarea> tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM