2015-11-09 49 views
0

我有兩個kendo菜單,我希望頁面被重新加載。但是,根據我們客戶的要求,他們不希望用戶能夠點擊後退按鈕。下面是我使用的代碼:如何在導航上使用eventlistener除了2件東西

<script> 
history.pushState(null, null, 'HomePage'); 
    window.addEventListener('popstate', function(e) { 
      history.pushState(null, null, 'HomePage'); 
    }); 
</script> 

基本上,我想觸發一切事件只是一個菜單項點擊這兩個劍道菜單。

感謝

回答

0

我把這個代碼在我的MVC項目的部分_layout.cshtml到最終解決問題。我仍然遇到的唯一問題是右鍵單擊後退按鈕功能仍在發生。

代碼:

history.pushState(null, null, $(location).attr('href')); 
    window.addEventListener('popstate', function() { 
     history.pushState(null, null, $(location).attr('href')); 
    });