【发布时间】:2013-02-11 06:29:52
【问题描述】:
不使用history.pushState是否可以重写浏览器的历史记录?
我有一个带有路由器的主干应用程序,看起来像这样:
routes: {
'posts': 'posts',
'modal': 'modal'
},
'before': function (args) {
//check if logged in
//do some various other setup tasks
//maybe delete modal routes from the history?
//forward to route
args.next()
},
'posts': function () {
//make and show posts
},
'modal': function (params) {
//edit user email preferences OR
//create a new post OR
//do various other crud operations
}
无论何时触发模态路由,我都希望防止将哈希值写入浏览器的历史状态。原因是,用户在历史倒退时不应该重新打开模态。
我查看了主干源代码,但没有看到任何简单地说 history = [] 的内容。
有没有什么方法可以在没有推送状态的情况下做到这一点?
【问题讨论】:
标签: javascript backbone.js routes browser-history hashchange