Hello Friends, In this unit, you will see a JavaScript code example that helps you to get the URL parameter value. You can use this piece of code in the visualforce page, salesforce lightning component or any other HTML page to read URL params value.

URL Parameter in Javascript

JavaScript code:
 function getURLParam(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        } 
    }
Example :
 <html>
    <head>            
        <body>
            <div id="pValue"></div>
            <script type="text/javascript">                
            function getURLParam(variable) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if (pair[0] == variable) {
                        return pair[1];
                    }
                } 
            }
            var name=getURLParam("name");                
            document.getElementById("pValue").innerHTML=name;                
            </script>
        </body>
    </head>
 </html>
Output:
See also:

Conclusion:
Hope you like this tutorial, for any query or suggestions please feel free to comment.
Thank you.