How get URL values using JavaScript

how to get emp_id value from this url using javascript and all values

If you don’t care about IE, You can use URLSearch

Or I’ve used a method similar to this (disclaimer: I found it on SO, so I’m not the author…)

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));

// query string: ?foo=lorem&bar=&baz
var foo = getParameterByName('foo'); // "lorem"
var bar = getParameterByName('bar'); // "" (present with empty value)
var baz = getParameterByName('baz'); // "" (present with no value)
var qux = getParameterByName('qux'); // null (absent)
1 Like

thanks man!

If you’re interested in how this works, we also have an article on this.


Thank you @James_Hibbard It’s really helpful for me :innocent::+1: