Get query string from URL via Javascript #javascript
// e.g URL: https://google.com/?id=foo
// getQueryString('id') // retruns "foo"
getQueryString: function(field, url){
var href = url ? url : window.location.href;
var reg = new RegExp( '[?&]' + field + '=([^&#]*)', 'i' );
var string = reg.exec(href);
return string ? string[1] : null;
}