Google Chrome: Refused to Execute Inline script

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

In light of change in chrome's content security policy, I have moved all the script in separate files and referencing them in html pages (background and popup) for my chrome extension. But I still get the following message

Refused to execute inline script because it violates the following Content Security Policy  directive: "script-src 'self' chrome-extension-resource:". 

This is my background page

<html> <head>     <script type="text/javascript" src="jquery.js"></script>     <script type="text/javascript" src="background.js"></script> </head> <!--<body onload = "Load();">-->  <body> </body> </html> 

You see there is no inline js but the error message is till there. What's the problem with my code and how can I fix it?

Note: I am using manifest version 2 and chrome version 21.0.1180.89

Thanks

回答1:

As the previous answer suggests when you update your extension to manifest version 2 the code of the extension and the code of the referred libraries have to be CSP compatible.

Updating your jquery library should be enough. Jquery supported CSP with this bug: http://bugs.jquery.com/ticket/11249



回答2:

The problem was solved by upgrading the jquery.js from version 1.4 to 1.7



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!