/ Published in: JavaScript

This code assumes a page is populated with divs with ids div_1, div_2, div_3 etc etc etc...
Some quick php to create 200 divs numbered as above:
Some quick php to create 200 divs numbered as above:
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script languate="javascript" type="text/javascript"> //Get the values from the url variable id //(getUrlVars Code URL: http://snipplr.com/view/19838/get-url-parameters/) function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value){ vars[key] = value;}); return vars; } //scroll to the specific div, assuming each div is named "div_(number)" function scrollToID() { document.getElementById("div_" + id).scrollIntoView(); } var id = getUrlVars()["id"]; window.onload=scrollToID(id); </script>
Comments
