browser history - replicate google maps URL behaviour with javascript? url+"/@foo" -
google map thing if browse to, say, australia, url changes to
https://www.google.com/maps/@-28.0345854,135.1500838,4z
i'm interested in doing on web application. far have this:
var baseurl = window.location.href.split("/@")[0] window.history.replacestate( {} , 'foo', baseurl+'/@foo' );
which works fine adding "/@foo" url
my problem that, after adding /@foo, url doesn't work, 404es.
i'm not interested in modifying brower's history, that's why use replacestate instead of pushstate.
anyway, there way js? or need server-side code serve appropriate page?
thankyou
you "need server-side code serve appropriate page". @
character still part of url , therefore needs handled server. if want handle kind of situation client side want use #
instead. after hash handle client side , not trigger new page load server.
several libraries use replicate routing in single page html app. example:
and many more.
Comments
Post a Comment