slide-drive
slide-drive copied to clipboard
Slide Permalink Is Not Exposed Anywhere if replaceState Is Not Supported
The Butter editor is unusable in IE9, but the only issue I could find in exported HTML-only presentations was this.
The deck.hash.js plugin only updates the current URL when switching slides if the history.replaceState
function is available. (It will be in IE10, but it's not in IE9.) Otherwise, it only updates the permalink displayed on the page.
The issue is that we don't have a permalink displayed on the page anywhere, so the permalink of the current slide isn't exposed anywhere for IE9 users. The plugin expects us to have one, and it will hide it for browsers that support replaceState
.
We should probably just add a visible link, but I was thinking about the problem of getting the same behaviour in IE9.
Presumably they're insisting on replaceState
because they don't want to pollute the browser history with slides. I think it would be possible to get the expected changing URL in IE9 without breaking the back button, at the expense of having three events listed in the history.
- When the page loads, set
location.hash = "#__BACK__"
, then setlocation.hash = "#"
- If the navigates to
#__BACK__
(by pressing their back button), triggerhistory.go(-2)
to get them off of our page as they probably intend. - When the slide changes, use
history.back()
to remove our current hash from the history and return to__BACK__
, then add the new new hash to the URL. (Giving us the same behaviour as if we usedreplaceState
, just requiring an extra history event as a buffer, which must come after the first history event from when the page loaded.)