Home > Web Front-end > JS Tutorial > Chrome extension page dynamic binding JS event prompt error_javascript skills

Chrome extension page dynamic binding JS event prompt error_javascript skills

WBOY
Release: 2016-05-16 17:00:37
Original
1383 people have browsed it

Problem description:

When developing a Chrome extension, when js is required in the popup.html of the page, directly writing JS in dynamically bound JS events will prompt:

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

Solution:

Reference external js in popup.html The file dynamically binds JS events, for example:

Copy code The code is as follows:



test.js:
Copy code The code is as follows:

var listbox = document.getElementById("showlist");
listbox.onclick=function (){
document.getElementById("player_sidebar").style.width = 100;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template