Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Is there a way to get query string values of a URL in JavaScript?

Damian99Damian99 USAPosts: 116Member

Can someone please let me know whether there is a way to get query string values of a URL in JavaScript?




  • DavidMDavidM USAPosts: 342Member

    Use the VanillaJS library as follows.

    function getParameterValueByName(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
        var results = regex.exec(;
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
Sign In or Register to comment.