-1

I have been searching online to peform window.close() using the javascript. I have a MVC application,when i click on logoff button the page should close.

I know that the window.close is not working now a days as there is some security reasons. Getting the message "Scripts may close only the windows that were opened by it".

Tried almost all the options to close the window but nothing works till now.

<a href="#" onclick="javascript:window.close();"> method1 <a/> 
<a href="javascript:window.open('','_self').close();">method2</a>
<a href="javascript:window.top.close();">method2</a>

Any help is appreciated.

Thanks

Dev

Devanathan.S
  • 1,362
  • 1
  • 14
  • 22
  • 1
    let's put it this way: "Why do you think that you can tell **my browser** when it should close some tab?" It's a matter of don't interfere with the users browsing experience/it's browsers behaviour. Instead of closing the tab/window, better redirect the user either to a logout page, or to the start page. – Thomas Apr 25 '17 at 13:36

1 Answers1

-1

I had this same scenario and researched a lot. I had to end up with using IE(Internet Explorer) or Edge browser. There are no other solutions for existing browsers

Only if you page is loaded from another page or web application or a homePage(which is also a web page), this is possible

Jins Peter
  • 2,368
  • 1
  • 18
  • 37