Hash in url with JS plugin

0

I wonder if anyone knows a plugin or script, which takes the hash from the url. But that is usual in all browsers. Which takes more than one hash per url. I know there are several examples on the internet, but I'm afraid it will not work on all browsers. So I would like an indication of a 100% usual script with the details given above ..

    
asked by anonymous 30.04.2015 / 11:31

1 answer

0

If this parameter is in query string I use this function and it works in IE, Chrome and Mozilla.

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

To use just call the query string the method will return the value.

Example

URL: link

       <script type="text/javascript">
           var queryString = getQueryString("hash");
           alert(queryString); // irá imprimir asdf01215df
      </script>
    
30.04.2015 / 14:26