0

I'm using the History API's replaceState() when a Bootstrap modal is displayed, so the user can share, bookmark, etc. the URL when the page is in it's current state. When a user closes the modal, the URL still contains the query string domain.com/page/?modal=url-friendly-name.

I cannot seem to get the URL to return to just domain.com/page/. How can this be accomplished?

I believe whatever code is needed, should be inserted in the following event listener:

$('#modal').on('hidden.bs.modal', function () {
 // return URL back to domain.com/page/
});

Any help would be greatly appreciated!

Cofey
  • 11,144
  • 16
  • 52
  • 74
  • rephrasing the question, does the link which is in the modal, user share it when modal remain open or share when modal closed? – Shehary Sep 30 '15 at 21:41
  • @Shehary When a user shares or bookmarks the URL while viewing a modal, the modal will re-appear upon page load. – Cofey Sep 30 '15 at 21:45
  • ok now, so the URL in the modal to bookmark is in this state `domain.com/page/?modal=url-friendly-name` – Shehary Sep 30 '15 at 21:49
  • @Shehary That's correct. However, if the modal is closed, I need the URL to go back to just domain.com/page/. – Cofey Sep 30 '15 at 21:53
  • I think this can help, http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript fetch link and split, with javascript or jQuery inside bootstrap hidden event listener – Shehary Sep 30 '15 at 22:35

0 Answers0