S
S
Sasha2015-12-10 16:36:29
JavaScript
Sasha, 2015-12-10 16:36:29

How to remove "#" from url and everything after it?

Hello.
Can you please tell me how to remove "#" from the url and everything that comes after it?
For example, there is a url like this: somesite.com/direct/#el-target04
How can I make it look like this when the page is reloaded: somesite.com/direct ?

Trying to implement with:
window.location.hash

Thanks.

upd_01
Found this solution:

history.pushState('', document.title, window.location.pathname);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yakov Vylegzhanin, 2015-12-10
@userAlexander

history.pushState("", document.title, window.location.pathname);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question