0

After my last question : Set opacity with js or close modal window

The function works, the modal window is well hidden. But when this modal window is created, the website URL becomes : http://url.com/#idModal

If the div is hidden, the URL stays with #idModal and I can't open an other modal window. Is there any way to recover the base URL? I tried with window.location but it reloads the page with #idModal...

Thank you!

Community
  • 1
  • 1
Ty Yt
  • 466
  • 2
  • 9
  • 25

1 Answers1

2

You can use:

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

It will remove hashtag part from current URI.

Here you can see the browser support of History API.

Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56