Just to confirm current browser window could never be closed through JS?
            Asked
            
        
        
            Active
            
        
            Viewed 183 times
        
    0
            
            
        - 
                    @j08691 can we delete this question? I think the answer is its not doable with js. Above question was asked in 2010. window functions changed since 2017 with security aspects. – Sep 24 '19 at 20:17
1 Answers
1
            
            
        So, the window.close method can only be called on windows that were opened by a script using the Window.open() method. 
For example, the following script will work:
var myWindow;
function openWin() {
  myWindow = window.open("", "myWindow", "width=200,height=100");
  myWindow.document.write("<p>This is 'myWindow'</p>");
}
function closeWin() {
  myWindow.close();
}
You just need to make sure you call close on the window that has a open called upon previously.
 
    
    
        shobhit1
        
- 634
- 7
- 18