I am attempting to run javascript in an external file within a HTML/EJS page. Code is as follows:
<body onload="initialize()">
//HTML content
<script src="/public/js/gallery.js"</script>
</body>
The "initialize()" function is located within the "gallery.js" file. The problem is that I am continuously getting an error which reads:
"Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-tPMkUWbNPBXQQ3rlbFhILb35szR89eQb3Z41bzLr+wQ='), or a nonce ('nonce-...') is required to enable inline execution."
I have tried a number of attempted fixes in my "head" tag on the page. These include "<meta Content-Security-Policy: script-src 'self' 'unsafe-inline'">", "Content-Security-Policy: script-src 'self'", and "meta http-equiv="content-security-policy content=script-src"...
This is maddening...I have spent hours trying to correct this. Can somebody PLEASE offer some explanation on what the problem is...??? I thank you in advance. Regards.
The 'gallery.js' file reads as follows:
addEventListener("load", initialize);
function initialize() {
//do stuff
}