Reputation: 635
I have this script:
<?php
header("refresh: 5;");
include 'theme.php';
ceklogin();
css();
echo <<<HTML
<script type="text/javascript">
var textarea = document.getElementById(\"wget\");
textarea.scrollTop = textarea.scrollHeight;
</script>
HTML;
echo " Wget log :<br>";
echo "<textarea name=\"text-info\" rows=\"30\" id=\"wget\" 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>';
?>
the javascript part doesn't work, it won't scrool to bottom on the textarea every time it refreshes the page, any ideas?
Update: I modified my script to be like this but still doesn't work
<?php
header("refresh: 5;");
include 'theme.php';
ceklogin();
css();
echo '<script type="text/javascript">
var textarea = document.getElementById(\"wget\");
textarea.scrollTop = textarea.scrollHeight;
</script>';
echo " Wget log :<br>";
echo "<textarea name=\"text-info\" rows=\"30\" id=\"wget\" cols=\"90\" readonly style=\"font-family: Arial;font-size: 7pt;\" >";
$file = file_get_contents('/www/wget.log');
echo $file;
echo "</textarea></div>";
foot();
echo '
</div>
</body>
</div>
</html>';
?>
Upvotes: 1
Views: 198
Reputation: 323
You could try moving your Javascript to the bottom of the body and putting this in a function:
(function() {
var textarea = document.getElementById(\"wget\");
textarea.scrollTop = textarea.scrollHeight;
})();
Upvotes: 0
Reputation: 15501
Try:
echo '<script type="text/javascript">
var textarea = document.getElementById(\"wget\");
textarea.scrollTop = textarea.scrollHeight;
</script>';
(Removed the <<<HTML
and reformatted the HTML string.)
Upvotes: 1