Chrome extension: managing multiple html pages in an extension -


i want have several html files in extension can open each of them according conditions or events. want a.html opened when user chooses option on context menu.

i tried following:

manifest.json:

{ "name":  "my extension", "version": "1.1", "background": { "page": ["background.html"] }, "incognito": "split", "permissions": ["tabs", "<all_urls>", "contextmenus"], "icons": { "16": "images/16.png" }, "manifest_version": 2 } 

background.html:

<!doctype html> <html> <head>     <script src="background.js"></script>     <script src='somewindow.js'></script> </head> <body> </body> </html>   

background.js:

var winid; chrome.contextmenus.onclicked.addlistener(function proccess_interested(info, tab){      chrome.tabs.create({active: false}, function(newtab) {      // after tab has been created, open window inject tab it.     chrome.windows.create(         {             tabid:      newtab.id,             type:       "popup",             url:        chrome.extension.geturl('a.html'),             focused: true         },function(window){                  winid = newwindow.id;           });     }); })  chrome.extension.onmessage.addlistener(function(msg, sender, sendresponse) {  if(msg.close_comment_win){     chrome.windows.remove(winid, function(){}); } }); 

somewindow.js:

function hide_win() {     chrome.extension.sendmessage({close_win: close}, function(response) {}); } 

a.html:

<!doctype html> <html> <head>  <script src='somewindow.js'></script>  head     //with tags, can't show here body <input type='button' value=' cancel ' onclick="hide_win()"></input>  </body> </html> 

the window opened when context menu clicked, when hitting cancel, it's not closed. console.log says: refused execute inline event handler because violates following content security policy directive: "script-src 'self' chrome-extension-resource:". guess reason a.html not part of extension, even though somewindow.js triggers sendmessage part of extension.

including a.html in extension through manifest isn't option no more 1 background html page can included.

of course same when putting chrome.windows.remove(winid, function(){}); directly in hide_win() without using sendmessage.

any ideas how job done?

just error says, against v2's content security policy have inline code in extension html pages. move handler js file , should work fine.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -