Answer the question
In order to leave comments, you need to log in
How to fix security policy error in google extension?
The problem is this: I am writing an extension that, when the button is clicked, adds the text entered by the user.
and in a regular html document, if you run it, everything works as it should, but when loaded as an extension, it stops working. Chrome throws popul.html:9 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
manifest.json code
{
"manifest_version": 2,
"name": "organizer",
"version": "1.0",
"browser_action": {
"default_title": "Organizer",
"default_icon": "log.png",
"default_popup": "popul.html"
}
}
<html>
<head>
<script type="text/javascript" src="dobavka.js"> </script>
</head>
<body>
<td><input type="text" id="sd" onfocus="this.value = ''" value="Ввести задачу " class="input_task" /></td>
<button onclick="addLi()">+</button>
<ol id="spisokst";">
</ol>
</body>
</html>
function addLi() {
var stroka = document.getElementById('sd').value;//дл¤ ввода названи¤ новой строки
if (stroka){
var ol = document.getElementById ("spisokst");//находим наш список
var li = document.createElement("LI");//создаем новый элемент списка
ol.appendChild(li);//присваиваем нашему спску новый элемент
var text = document.createTextNode(stroka);//создаем новый узел текст
li.appendChild(text);//присваиваем этот текст нашему новому пункту списка
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question