Window close not working on react js app, How to close current tab on browser onclick back button?

Viewed 683

Want to detect user on last tab and then if user click back button browser need to close.

I've tried this.

         window.onpopstate = e=>{
            e.preventDefault();
            if(e.state==null){
                let win = window.open("about:blank", "_self");
                     win.close();    
            }
        }

above code opening new tab but not closing current tab.

Note this error too. "Scripts may close only the windows that were opened by it."

0 Answers
Related