meh
meh

Reputation: 19

Close button in chrome packaged apps

I'm working on a chrome packaged app, and the white window was annoying me. So I decided to make my own close/minimize/maximize buttons. But, onclick doesn't work. And my workaround doesn't either. HTML:

<a href="#" id="close"><img src="close.png"/></a>

JavaScript:

var close = document.getElementById('close');
close.addEventListener('click', chrome.app.window.current().close);

Upvotes: 0

Views: 2049

Answers (2)

ateebahmed
ateebahmed

Reputation: 182

Above answer works if you use a separate .js file in your .html or use the one .js file which you use for your background scripting. I used this method.

window.onload = function() {
    document.getElementById('/*element-id*/').onclick = function() {
        chrome.app.window.current().close();
}}

Upvotes: 1

Laurent Trillaud
Laurent Trillaud

Reputation: 363

You close an packaged app like a web app with the code :

  document.getElementById("close").onclick = function() {
    window.close();
  }

You have sample here : https://github.com/GoogleChrome/chrome-app-samples/blob/master/frameless-window/frameless_window.js

In this frameless package app sample : https://github.com/GoogleChrome/chrome-app-samples/tree/master/frameless-window

Upvotes: 0

Related Questions