Hacker News new | ask | show | jobs
by vmind 5550 days ago
Would it be possible to use pushState as the main mechanism on the client, and use a #! as a fallback? You would end up with two different possible URLs, but if the same library handles the calls then it would be fairly straightforward to move from one to the other.
1 comments

Yes, this is possible.

If you do capability detection by checking to see if window.history.pushState exists, then you can configure RouteMap.handler to be tied to history events. Otherwise, you can set the prefix by calling RouteMap.prefix('!').

EDIT: I re-read your question, and I think that I misunderstood. I do think what you're asking is possible, and what I stated above is a piece of what you'd need to do. Basically, instead of simply binding RouteMap.handler to either onhashchange or onpopstate, you'd probably have to write an event listener for both of those methods + a window onload handler all of which send their respective portions of the URL that you care about to RouteMap.handler.