Preventing pages being open in a new tab/window

前端 未结 3 489
悲&欢浪女
悲&欢浪女 2020-12-31 15:19

I am working on a project that behaves very strange when the user open pages in a new tab or in a new window, causing the app to crash.

I need some javascript that

3条回答
  •  离开以前
    2020-12-31 15:24

    For me, the other answers are no sensible option, since some hrefs in my document are procedurally changed. This block of code works though:

    document.documentElement.addEventListener('click', function (event) {
      if(event.ctrlKey){event.preventDefault()}
    });
    

提交回复
热议问题