Javascript Scrolling to a PHP variable Scroll point passed through a link -


i'm trying create page has anchor tags link page containing variable javascript function on other page scroll window to. is, pointing link next page so:

<a href="products/cartridges/?scrollpoint=600">721p</a> 

with php script on receiving page geting linked variable , echoing javascript in head of document.

<?php> $scrollpoint = $_get["scrollpoint"]; echo "<script type='text/javascript'>"; echo "var scrollpoint = " . $scrollpoint . ";"; echo "function scrollwindow {";  echo "window.scrollto(0,$scrollpoint);"; echo "}";  echo "window.onload = scrollwindow;"; echo "</script>"; ?> 

the php should executed before javascript runs, doing wrong here?

i prefer not use jquery, or scrolling div id, page relatively short, , spans being scrolled aren't assigned ids.

two things:

  1. your function signature scrollwindow needs have () in order valid js: function scrollwindow () {...}
  2. this needs inserted near bottom of page in order fire @ time expect to. i'm not sure it's 100% it'll fire , scroll right spot every time, if page simple it'll work.

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -