Is it possible to remove parameter from query-string with js, I have tried below one unfortunately its works in browser console not in JS file.
var clean_uri = location.protocol + "//" + location.host+location.pathname;
window.history.replaceState({}, document.title, clean_uri);
what would be the best way to do it.
The reason this would only work in the browser is that the window.history API is only available in your browser. I'm not quite sure what you mean by 'from file'. But as one of the commenters pointed out the problem is in the context of where it is executed. If for instance you are executing this in a Node environment rather than a browser, there is no window.history api. Node doesn't even have a window object.
Since you've added an AngularJs flag, it might be that the routing inside the app is listening to changes to the URL and will act on them. Angular may have it's own way of allowing you to change the URL but I'm not familiar enough to help with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With