hash # url – single page website navigation

function hashChecker(){
    var hash = (window.location.hash).replace('#', '');
    if (hash.length == 0) {
        //no hash do something   
    } else {   
        //else do something with hash
      if (window.location.hash == "#hashname") {
      // do something
        }
    }
}

jQuery: Using window url parameter

Let’s say we have passed a parameter to URL: www.mysite.com/?page=test

To collect the data form parameter we can use this function:

function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};

use of this code:

getUrlParameter('page');

or

if (getUrlParameter('page') == 'test'){
// do something
}