How to disable Browser back button in Angular 2

2019-01-26 12:39发布

I'm developing a web site using Angular 2. Is there any way to disable or trigger Browser back button using Angular 2?

Thanks

7条回答
啃猪蹄的小仙女
2楼-- · 2019-01-26 13:30

Try this

<script type = "text/javascript" >
history.pushState(null, null, 'pagename');
window.addEventListener('popstate', function(event) {
history.pushState(null, null, 'pagename');
});
</script>

where change 'pagename' to your page name and put this into head section of page.

查看更多
登录 后发表回答