I am trying to create chrome extension, however my browser action click does not work! I've tried pretty much everything. Here is my setup:
manifest.json:
{ "name": "blah", "version": "1.0", "description": "blah", "browser_action": { "default_icon": "icon1.png", "popup": "popup.html" }, "permissions": [ "bookmarks", "tabs", "http://*/*", "https://*/*" ], "background_page": "background.html" }
popup.html:
<html> <head> <script> <!-- Try adding the listener in popup.html --> chrome.browserAction.onClicked.addListener( function(tab){ console.log("Hello from popup"); // This does not show up either } ); </script> </head><body> Hello </body> </html>
background.html:
<html> <head> <script> console.log("Background.html"); // This gets displayed. O.K. function hello() { console.log("HELLO"); // THIS NEVER GETS DISPLAYED } // Supposed to Called when the user clicks on the browser action icon. chrome.browserAction.onClicked.addListener(hello); </script> </head> </html>
But no matter how hard i click on the Icon nothing happens and "HELLO" is not printed out in the console!
I am using Chrome 4.0.249.43. I installed the Beta version BUT it is exactly the same as the released version (same verion number). Could that be a problem?
browserAction.onClicked:- Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. Show activity on this post. I had some problems too while trying to create a chrome extension. Make sure you reload the extension after any change to the manifest.json or the background page.
Browser Extensions Click on “Add to Chrome” button to install the extension on your browser. After installing, open the webpage and click on the extension icon on the address bar. Select, “Enable Right Click” option to copy the content from the webpage with right-click.
Don't use browser actions for features that make sense for only a few pages. Use page actions instead. Do use big, colorful icons that make the most of the 16x16-dip space. Browser action icons should seem a little bigger and heavier than page action icons.
In order to use the chrome.action API, you need to specify a "manifest_version" of 3 or higher and include the action key in your manifest file. ... ... Each of these values is optional; an empty dictionary is technically allowed. These properties are described more below. The icon is the main image used in the toolbar button.
You cannot have a "popup" with an onclick event. Remove the popup.html from the manifest file. And keep the background page, and it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With