Javascript在google chrome扩展中不起作用

Javascript在google chrome扩展中不起作用,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,我正在尝试为google chrome创建一个简单的扩展。我包括我使用过的代码。但包含的脚本不起作用 index.html <!doctype html> <html> <head> <script src="ext.js"></script> </head> <body> <button id='test'>Test</button> <body> &

我正在尝试为google chrome创建一个简单的扩展。我包括我使用过的代码。但包含的脚本不起作用

index.html

<!doctype html>
<html>
<head>
      <script src="ext.js"></script>
</head>
<body>
      <button id='test'>Test</button>
<body>
</html>
ext.js

function clickHandler(e) {
  alert('its working');
}

document.addEventListener('DOMContentReady', function () {

  document.querySelector('button')
          .addEventListener('click', clickHandler);
});

如何解决此问题?

它是DOMContentLoaded而不是DOMContentReady-devnull69

您错过了body的结束标记。你的分机也一样吗?它是
domcontentload
而不是
DOMContentReady
function clickHandler(e) {
  alert('its working');
}

document.addEventListener('DOMContentReady', function () {

  document.querySelector('button')
          .addEventListener('click', clickHandler);
});