Skip to content
Advertisement

CSP issues with javascript and css – password visibility toggle

I am currently working on some frontend development on a server. However when I try to add inline css and javascript for my password visibility toggle I keep getting the same CSP errors in google chrome.

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' ssl.google-analytics.com

The code I have tried :

JavaScript

It works great on both internet explorer and microsoft edge, but refuses to work on google chrome. I would need help figuring out this problem. Is it that CSP has no support for $(“.toggle-password”).click? I also tried move the js and css into seperate external files but without success.

Advertisement

Answer

Try adding ‘unsafe-inline’ to your CSP list.

E.g.,

script-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval’ ssl.google-analytics.com

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement