0

I have two pop-ups, one for confirmation and the other for notification. I use

1-onclick = 'window.location.href = "#confirmation"' to open confirmation box, then I use

2-window.location = "mypage.php#" after user confirms the action, in order to clear browser link from ..../mypage.php#confirmation hash, then finally I use

3-window.location = "#notification". in order to open notification pop-up.

This action returns user to the top of the page. I wonder if there is any way that I can clear browser link from #confirmation hash so that I would skip second step that makes user turn back to the top of the page.

Ahmet
  • 115
  • 11
  • 1
    Why not just skip it and instead of clearing `window.location` go straight to `#notification` ? – anteAdamovic Oct 24 '17 at 23:44
  • There's absolutely a way, but **how** are you clearing it? Through JavaScript? Through PHP? – Obsidian Age Oct 24 '17 at 23:44
  • Because it will add hashes like this: mypage.php/#confirmation#notification. Thats what I experienced. – Ahmet Oct 24 '17 at 23:44
  • 1
    Then you are adding the hash incorrectly, `location.hash = "foo"` – Endless Oct 24 '17 at 23:46
  • Through JavaScript – Ahmet Oct 24 '17 at 23:46
  • @Ahmet I'm not sure what you're doing but I just tried it in my browser `window.location.href = '#test';` adds `#test` to my url, calling it again with `window.location.href = '#test2;` doesn't add another hash but replaces current `#test` with `#test2` – anteAdamovic Oct 24 '17 at 23:47
  • I don't know why it happens but probably because final window.location is run in the function and the function runs while the page is at mypage.php#confirmation state. – Ahmet Oct 24 '17 at 23:49
  • Gonna try location.hash right away. – Ahmet Oct 24 '17 at 23:51
  • location.hash instead of window.location is my answer. Thanks. – Ahmet Oct 24 '17 at 23:58

0 Answers0