Removing hash from URL
After removing the hash from the url using the page window.location.hash=''
that reloads in firefox.
EDIT
Example:
wwww.Mysite.come/#page=1
On button click I remove the hash value using the following code
window.location.hash=''
After deleting the hash page, a restart occurs in firefox.
I don't want to reload the page I just want to remove the hash from the URL
How to fix it?
source to share
From https://developer.mozilla.org/en/DOM/window.location :
Examples of
When the location object property changes, the document will be loaded using the url as if window.location.assign () was with the changed url.
This question, I think, addresses what you want to use jQuery:
Change hash without reloading in jQuery
Other related questions:
Change url in browser without loading new page using JavaScript
How to remove hash from window.location from JavaScript without refreshing the page?
How can I change Firefox's window.location.hash without creating a page reload?
source to share
If I understand correctly,
<a href="#someElementID" id="myLinkName">Some Text</a>
clicking on the said link in the browser usually results in a hash being added in the address bar like www.websitename.com # someElementID <is what you are looking for to prevent , yes
The solution I just tested that works and does NOT refresh the page:
event.preventDefault();
This works on the 'click ()' event, which includes anchor tags that refer to element ids, like in the anchor tag example above. In action, it will look like this in your click () event:
<script>
$('#myLinkName').click(function(){
event.preventDefault();
//the rest of the function is the same.
});
</script>
Now clicking on the same link leaves the address bar with the same url www.websitename.com, WITHOUT the added hash on clicking on the anchor.
source to share