Using PHP value in javascript - working in alert() but not getelementbyid -
i using this:
$newpostid_fromcookie = $_cookie['scrolltobottom']+5000; echo " <script> window.onload = function () { //document.getelementbyid('$newpostid_fromcookie').scrollintoview(); alert('$newpostid_fromcookie'); } </script> ";
this correctly shows value cookie in alert, getting 'is null' error when trying use value in getelementbyid.
how can use value in this?
your $newpostid_fromcookie
seems integer. in xhtml, not valid , maybe browser not it. should use string (with prefix example):
document.getelementbyid('cookie_$newpostid_fromcookie').scrollintoview();
of course, change html in consequence.
Comments
Post a Comment