Answers for "js remove url GET parameter"

0

js remove url GET parameter

function removeParams(sParam)
{
            var url = window.location.href.split('?')[0]+'?';
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;
         
            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);
Posted by: Guest on July-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language