How to remove parameters in URL using JavaScript

How to remove parameters in URL using JavaScript

JavaScript (“JS” for short) is a full-fledged dynamic programming language that, when applied to an HTML document, can provide dynamic interactivity on websites. 

In this tutorial we will show you How to remove parameters in URL using JavaScript. JavaScript  code snippet to remove the dynamic variables stored in the url as parameters, and check them as JavaScript variables ready for use with your scripts.


function removeParams(sParam)
            var url = window.location.href.split('?')[0]+'?';
            var sPageURL = decodeURIComponent(,
                sURLVariables = sPageURL.split('&'),
            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');
                if (sParameterName[0] != sParam) {
                    url = url + sParameterName[0] + '=' + sParameterName[1] + '&'
            return url.substring(0,url.length-1);

window.location = removeParams(parameter);


And this is how you can use this function assuming the URL is,

window.location = removeParams('technology');

Share Your Comments