148
rated 0 times
[
151]
[
3]
/ answers: 1 / hits: 32923
/ 8 Years ago, tue, april 19, 2016, 12:00:00
I want to read out an url parameter using jquery and bind this one in a variable. I've seen a lot of ways to solve it but definitely no one worked for me.
http://relaunch.headonline.de/projekte/#filter=kataloge-database
-> I'm using a '#' instead of a '&' or '?'!
This is my current javascript:
function $_GET(param) {
var vars = {};
window.location.href.replace( location.hash, '' ).replace(
/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
function( m, key, value ) { // callback
vars[key] = value !== undefined ? value : '';
}
);
if ( param ) {
return vars[param] ? vars[param] : null;
}
return vars;
}
var filter = $_GET('filter');
More From » jquery