I am designing a toolbar for chrome. This is my code in background.html:
<script>
function addToolbar() {
return function(info, tab) {
chrome.tabs.executeScript(tab.id, {file: "toolbar.js"})
};
};
addToolbar();
</script>
In the toolbar.js there is the code for create an iframe and append it to the document.
The problem is that “addToolbar()” function is not executed automatically and so the toolbar doesn’t appears.
How can I do that ?
EDIT:
my toolbar.js code:
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "http://www.example.com/mytoolbar.html");
iframe.style.cssText='position:fixed;width:100px;height:50px;bottom:0px;left:0px;';
(document.body||document.documentElement).appendChild(iframe);
Your function
addToolbarjust returns another function. It doesn’t execute it.If you want to execute the returned function, you can do it this way:
Or you should execute what you need to be executed directly, in the
addToolbarfunction: