1
是否可以在不使用history.pushState
的情況下重寫瀏覽器的歷史記錄?骨幹 - 覆蓋Hashchange歷史
我有一個路由器主幹應用程序,它看起來是這樣的:
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 = []
。
有沒有辦法做到這一點沒有推狀態?
好,我敢肯定這會工作,但不是唯一的手動觸發路由時稱爲導航方法?在我的應用程序中有很多實例,我無法做到這一點(鏈接是共享,通過電子郵件或其他應用程序進來) – 2013-02-25 23:38:00
當按下後退按鈕時,我將如何調用該功能? – 2013-03-04 13:27:55
我已經更新了我的答案,通過添加和類例子,並在'#myButton'按鈕上的onclick事件 – socrateisabot 2013-03-04 18:38:12