Luke Toss
Luke Toss

Reputation: 386

Close Chrome extension with button

I am trying to close a chrome extension on-click of a button. The window is the only window open for this app. I thought the below would work but receiving the following console errors.

I am referencing jQuery in my HTML. All I want it to click a button and close my chrome app.

Uncaught TypeError: Cannot read property 'current' of undefined

$(document).ready(function() {
  $("#close").click(function() {
    chrome.app.window.current().close();
  });
});

The duplicate in no way explains my issue

Upvotes: 4

Views: 3944

Answers (1)

Shiven Sinha
Shiven Sinha

Reputation: 696

Try this from the window:

window.close();

Upvotes: 12

Related Questions