javascript - Get url parameter with jquery -


i want read out url parameter using jquery , bind 1 in variable. i've seen lot of ways solve no 1 worked me.

http://relaunch.headonline.de/projekte/#filter=kataloge-database

-> i'm using '#' instead of '&' or '?'!

this 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'); 

var url = window.location.href; var arguments = url.split('#')[1].split('='); arguments.shift(); 

working example

var url = "http://relaunch.headonline.de/projekte/#filter=kataloge-database";  var arguments = url.split('#')[1].split('=');  arguments.shift();  alert(arguments)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


var url = window.location.href; var arguments = url.split('#').pop().split('=').pop(); 

working example

var url = "http://relaunch.headonline.de/projekte/#filter=kataloge-database";  var arguments = url.split('#').pop().split('=').pop();  alert(arguments)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -