Skip to content

alert called by onload event not running? [closed]

I’m creating a chrome extension, but I’m struggling with the Onload event. I’m not sure what’s wrong with my code. It works when I run it from this code snippet, but not in my text editor. I’ve tried disabling Jslint but it still won’t show the alert. The problem could be in running the function, calling the alert, or calling the onLoad event, but I’m not sure. I’m testing it using a chrome-based preview tool in the brackets text editor. Any idea what’s going on and why?

 function showAlert() {
    alert ("you are an idiot");
  }
<script src="justanotherfile.js"></script>
<body onload="showAlert()"></body>

Answer

Did you include this in the manifest file?

"scripts": [
   "justanotherfile.js"
]