Rohit Azad Rohit Azad - 5 months ago 12
HTML Question

How to find url parameter # with value in javascript

I need to find url parameter # with value in javascript.

my url is like:

i want to find this value

I find this How can I get query string values in JavaScript?

but how to find this value in url?


This will filter the sid into the sid-variable wherever you put your hash.

var url_arr = window.location.hash.split('&'),
    sid = '';

url_arr.filter(function(a, b) {
    var tmp_arr = a.split('#')
    for (var i in tmp_arr)
        if (tmp_arr[i].substring(0, 3) == 'sid')
            sid = tmp_arr[i].substring(3, tmp_arr[i].length)

console.log(sid) // Will output '53239948'

Old answer:

var hash_array = window.location.hash.split('#');
hash_array.splice(0, 1);