Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing hash from URL

After removing hash from URL using window.location.hash='' page getting reloaded in firefox.

EDIT

Example:

wwww.Mysite.come/#page=1

On a click of button I am removing hash value using following code

window.location.hash=''

After removing the hash page is getting reloaded in firefox.

I don't want to reload page I just want to remove hash from URL

How to fix it?

like image 821
suma Avatar asked Nov 27 '22 09:11

suma


1 Answers

Just in case somebody else is still looking for a solution to this. Try this when the page loads.

history.pushState("", document.title, window.location.pathname);
like image 179
Carlos Martinez T Avatar answered Dec 04 '22 07:12

Carlos Martinez T