H
H
habrdima2015-07-03 02:09:37
Google Chrome
habrdima, 2015-07-03 02:09:37

Why doesn't alert work for popup.html?

manifesto

{
  "name": "bm - 2",
  "description": "Make the current page bm",
  "version": "2.0",
  "permissions": [
  "tabs"
  ],
  "background": {
    "scripts": ["background.js"]
  },
  "browser_action": {
    "default_title": "bm - 2",
    "default_popup": "popup.html"
  },
  "manifest_version": 2
}

the code
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">

  <script>
    function f() {
 
        alert("привет");
   
    }
  </script>
</head>
<body>
  <input type="button" onclick="f()" value="привет"/>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Datsko, 2015-07-03
@m1sh2

most likely because of this https://developer.chrome.com/extensions/contentSec...
try this:

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <script src="js.js"></script>
</head>
<body>
  <input type="button" onclick="f()" value="привет"/>
</body>
</html>

js.js content:
function f() {
      alert("привет");
}

UPD:
try to do via:
for example:
document.addEventListener('DOMContentLoaded', f); // вариант для теста

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question