Whenever I click on Stack-Snippets®'s in any post, a new entry is made in my tab's history (the one for the back and forward buttons, accessible through window.history
in js).
I like to keep my tab's history clean, and I expect to see only new tab's history entries for when I really change from page A to page B. But here, I stay on the same page, only an ajax POST request* is made to load the content of an iframe, so I can't make a sense to this behavior.
// you can try it here, even if the color of the button is different
When writing answers from inside the Stack-Snippets® it can grow really big, to an extent that the back button of my browser becomes completely useless, and sometimes requiring me to go inside the whole history to come back to the page I was in before.
I didn't searched a lot, but I couldn't find a clear call to pushState
, so I'll guess it's not made on purpose and tag this question as bug.
* Digging a little bit in snippet-javascript.en.js, I can now see that the request is actually not made through AJAX, but through an HTML <form>
, which will explain the why it happens, remains the why it has been made like this, does SO really support IE<7?
| Browser + Version | OS | Repro | Notes
| ----------------- | ------------ | ----- | -----
| Firefox | | |
| <50 ~ 57 | OsX Sierra | true |
| 55 | Arch Linux | true |
| 55 | Android 7 | true |
| 55.0.3 | Debian | true |
| 55.0.3 | Windows 10 | true |
| Chrome | | |
| 60 ~ 63 | OsX Sierra | true |
| 60 | Windows 10 | both |//Some can't repro, some can only on second and further clicks, some can directly
| 60 | Android 7 | true |//Not recorded in app's "back" menu, but in device back button...
| Safari | | |
| 10.1.2 | OsX Sierra | true |//Records for long "back" button press (equivalent to right click in other browsers), but not for single 'back' button press
| Internet Explorer | | |
| 11.1715 | Windows 10 | true |//Only on second and further clicks
Note: while writing this question, I noted that here on META, this history is eventually cleared after some time. This doesn't seem to happen on main, but would mean that the issue is at least known, so maybe I should reformulate as a feature-request so that this clearing is also implemented on main, and that the timeout is lowered (e.g to 0).
pushState
didn't exist and IE didn't care about changing#
hashes in the URL. Maybe snippets exhibit this behavior since they have to reset the iframe document in order to update the snippet - perhaps if they replaced the iframe with a fresh one this could solve the issue - but I don't know, I haven't read the SO JS code, so hopefully an SO dev will comment.Windows 10, 60.0.3112.113 (Official Build) (64-bit) (cohort: Stable)
both on my usual cocktail of extensions as well as with all extensions disabled