$(document).ready(function() { if(document.getElementById('presults') != null) { //only do this on the results page //On page load change the page according to the value of page in the hashfield var pageNumber = parseHash("page"); if(pageNumber > 1) //it's not nessesary to call the function if the page number is 1 { changepagefromhash(pageNumber); } $(function(){ //Listen for a hashchange and update the page if nessesary $(window).bind( 'hashchange', function(){ var pageNumber = parseHash("page"); if(pageNumber != null) { changepagefromhash(pageNumber); } }) }); } }); function parseHash(x) //Returns a value from the hash field in the form someurl.dtx#name=value where x is the name { var hash = location.hash.substring(1); var args = hash.split("&"); var name; var value; var arg; for(i=0;i