0

I am trying to add the event click listener on button using jQuery.

When i click the button its works fine but getting the below error on chrome://extension

Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

Here is my chrome extension popup : enter image description here

I have added the click event listener just hide and show using jQuery.

But its work fine getting error in chrome://extension.

Included JavaScript file in popup html

enter image description here

Sky Talawar
  • 45
  • 1
  • 6
  • You probably look at the old error in chrome://extensions page. Click `clear all` button to remove it. Note that the popup is a separate window so it has its own separate devtools: right-click inside the popup and select "inspect" in the menu. – wOxxOm Nov 21 '20 at 12:53
  • I have cleared the error still getting the popup inspect tool – Sky Talawar Nov 23 '20 at 03:55
  • It means the error is elsewhere, see [this answer](https://stackoverflow.com/a/25721457). – wOxxOm Nov 23 '20 at 04:13
  • Yes, I have already followed that, created one external js file and included in popup.html. The event click listener is working but getting the error in console. – Sky Talawar Nov 23 '20 at 04:31
  • Is the any changes in menifest.json ? – Sky Talawar Nov 23 '20 at 04:46
  • You're not showing us the entire code so we can't help. The only explanation I have is that you didn't fix all occurrences. – wOxxOm Nov 23 '20 at 05:21
  • I have shared the one image in that i have link the script file name : home-scipt.js in home script.js i have write the some js code like add event listener in both normal js and jquery js Like : document.addEventListener('DOMContentLoaded', function () { document.getElementsByClassName("showMysite")[0].addEventListener("click", function () { document.getElementsByClassName(".panelDiv")[0].style.display = "block"; document.getElementsByClassName(".mysites")[0].style.display = "none"; }); }); – Sky Talawar Nov 23 '20 at 06:15
  • 1
    This is not the entire code. Your HTML must have an inline js handler somewhere. – wOxxOm Nov 23 '20 at 06:38
  • Solved the error, Can't use the href="javascript:void(0) in anchor tag" – Sky Talawar Nov 23 '20 at 06:51

0 Answers0