close
在開發建置一個 Web 系統時,倒退鍵可是個大麻煩,有些的使用者已經習慣使用倒退鍵將頁面倒回去看或者修改資料,這可是違反了資料安全的呢?
為了限制使用者我這個壞習慣, 所以要加些工, 讓系統在按下倒退鍵時仍停留在原頁面,以保障資料的安全。
我的作法是
1.在每頁的頁面上加上
<script>
function BackKey(){window.history.forward();}
setTimeout("BackKey()", 0);
window.onunload=function(){null};
</script>
2.在每頁的表單轉入時加上
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetAllowResponseInBrowserHistory(false);
嗯, 搞定.
全站熱搜
留言列表