Javascript 如何在导航上使用eventlistener除了两件事
我有两个剑道菜单,我想在那里重新加载页面。但是,根据客户的请求,他们不希望用户能够单击后退按钮。下面是我使用的代码:Javascript 如何在导航上使用eventlistener除了两件事,javascript,jquery,model-view-controller,kendo-ui,Javascript,Jquery,Model View Controller,Kendo Ui,我有两个剑道菜单,我想在那里重新加载页面。但是,根据客户的请求,他们不希望用户能够单击后退按钮。下面是我使用的代码: <script> history.pushState(null, null, 'HomePage'); window.addEventListener('popstate', function(e) { history.pushState(null, null, 'HomePage'); }); </script>
<script>
history.pushState(null, null, 'HomePage');
window.addEventListener('popstate', function(e) {
history.pushState(null, null, 'HomePage');
});
</script>
基本上,我想触发所有的事件,除了一个菜单项,点击这两个剑道菜单
谢谢为了最终解决这个问题,我将这段代码放在了_layout.cshtml中的MVC项目部分。我仍然遇到的唯一问题是右键单击后退按钮功能仍然存在 代码:
history.pushState(null, null, $(location).attr('href'));
window.addEventListener('popstate', function () {
history.pushState(null, null, $(location).attr('href'));
});