# Refused to execute inline event handler because it violates the following Content Security Policy

**URL:** <https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371>\
**Category:** Ask the community\
**Created:** [March 21, 2023, 10:30am UTC](https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371 "2023-03-21T10:30:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Quel](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@Marc\_Quel](https://community.appfarm.io/u/Marc_Quel)\
**Post date:** [March 21, 2023, 10:30am UTC](https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371/1 "2023-03-21T10:30:38Z")

</div>

I am working with Coded Components, and when I try to remove any html element in a javascript script the following error shows:

“Refused to execute inline event handler because it violates the following Content Security Policy”

The line of the code that is making the error show is the following one:  
ul.querySelectorAll(“li”).forEach(li =\> li.remove());

Is there any way in which I can remove the Content Security Policy line that is causing this problem?

Thank you.

---

<div class="post-metadata">

**Author:** ![nejrabrc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/nejrabrc/32/131_2.png) [@nejrabrc](https://community.appfarm.io/u/nejrabrc)\
**Post date:** [March 21, 2023, 11:24am UTC](https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371/2 "2023-03-21T11:24:19Z")

</div>

Hello Marc!

I believe that the problem lies in the external resources that you might be using and referencing in your Coded Component script. Try following the instructions under **Content Security Policy** in the article here:

> **[Coded component](https://docs.appfarm.io/library/ui-components/coded-component#content-security)**

---

<div class="post-metadata">

**Author:** ![Marc\_Quel](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@Marc\_Quel](https://community.appfarm.io/u/Marc_Quel)\
**Post date:** [March 21, 2023, 4:20pm UTC](https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371/3 "2023-03-21T16:20:25Z")

</div>

It is weird because in this coded component I am not using any external resource. I attach some screenshots here so you can see how the coded component looks like:

HTML Content:  
 ![Screenshot 2023-03-21 at 17.18.31](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/75d244d0c55f18b7f4904eff7e6c3e0628a69012.png)

Script:

 ![Screenshot 2023-03-21 at 17.18.57](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/a497be7924ae9bf4f5e6236e843c218203ce75fc.png)

Coded component  
 ![Screenshot 2023-03-21 at 17.19.55](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/6cec355f2141b4045b6efb414d81d75a00e81948.png)

---

<div class="post-metadata">

**Author:** ![marcq](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@marcq](https://community.appfarm.io/u/marcq)\
**Post date:** [March 21, 2023, 5:57pm UTC](https://community.appfarm.io/t/refused-to-execute-inline-event-handler-because-it-violates-the-following-content-security-policy/371/4 "2023-03-21T17:57:08Z")

</div>

I have solved the issue. I think I have identified what was creating the CSP error.

 ![Screenshot 2023-03-21 at 18.54.06](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/be73528ef3b3b4947e0fee61ec3c4257becc787b.png)

As I have understood, what was triggering the error was setting the event listener onclick to an HTML element in the way that is shown in the screenshot with Javascript.
