Can I use Iron-Router in Meteor to push a new state onto the browser's history, without going to a new URL?
I would like to show a modal but enable to user to hide it again using the back button.
AFAIK you can't push browser state "silently" with the Iron Router package. However you can use one of these methods or the HTML 5 History API package that wraps this package - https://github.com/devote/HTML5-History-API
Haven't tried this, but I think something based on
Router.go(Router.current().request.url + '/modal')`
might work. You define your route with an optional parameter, and if it's 'modal'
then display the modal. That may lead to problems if you have URL parameters, in which case you'd have to get more clever with the URL.
来源:https://stackoverflow.com/questions/22062342/pushing-new-state-for-same-url-in-iron-router