问题
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
来源:https://stackoverflow.com/questions/12472455/google-chrome-refused-to-execute-inline-script