harsrawa
harsrawa

Reputation: 422

Close browser tab and exit Angular2 application

I am working on an Angular2 application. In this application, I want to provide a button to the user which when clicked will close the application and the browser tab in which it was opened.

I tried searching for the solution but didn't find anything much on it. One approach suggested was to call onDestroy for all the components to prevent any memory leak. However I don't have much concrete to go forward.

Upvotes: 3

Views: 8479

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 19622

No you cannot as of now it is only possible in IE AFAIK and with chrome or firefox you will encounter error like this

app.component.ts:43 Scripts may close only the windows that were opened by it

You can look at this answer for more info https://security.stackexchange.com/questions/133744/why-do-browsers-disallow-script-closing-an-opener-window-yet-allow-changing-its

Upvotes: 3

Related Questions