1

I wan to remove parameter from URL without reloading or refreshing page.

I used below code for that, and it's working fine.

jQuery(document).ready(function($) {    
    window.history.pushState("", "", "/" );
});

But problem is if I click on browser back button I can see parameters in url.

1

1 Answer 1

7

That's because pushState adds a new entry to the browser history.

Use replaceState instead, to replace the current entry.

jQuery(document).ready(function($) {    
    window.history.replaceState("", "", "/" );
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.