H
H
habrdima2016-04-10 00:10:33
JavaScript
habrdima, 2016-04-10 00:10:33

The function in the chrome app does not work, why?

Here is background.js

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('index.html', {
    'outerBounds': {
      'width': 400,
      'height': 500
    }
  });
});

Here is the manifest
{
  "manifest_version": 2,
  "name": "Codelab",
  "version": "1",
  "icons": {
    "128": "icon_128.png"
  },
  "permissions": [],
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  }
}

This is index
<!DOCTYPE html>
<html>
<head>
    <title>test</title>
    <script src="js.js"></script>
</head>
<body> 
    <button id="b" type="button">click me</button>
</body>
</html>

This is js
document.addEventListener('DOMContentLoaded', function () {
     function f(){
    alert("Привет")
            }
document.getElementById("b").addEventListener('click', f);
 })

no alert, no console, nothing is shown, why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question