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.

How remove parameters URL using JavaScript



function removeParams(sParam)
            var url = window.location.href.split('?')[0]+'?';
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                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');



Prakash S

Prakash S

I would like to introduce myself as a Software professional opting for the career in software industry. I'm Prakash S, a MCA graduate and trained as industry level practice for Software technology. Basically I am a PHP Developer but now days exploring more in HTML5, CSS, AngularJS and jQuery libraries.