Chrome browser Action click not working

2,455 views
Skip to first unread message

Prerak Kaushik

unread,
Oct 29, 2010, 4:13:47 AM10/29/10
to chromium-...@chromium.org

Hello,

This is my manifest.json file

{
 
"name": "My First Extension",
 
"version": "1.0",
 
"description": "The first extension that I made.",
 
"background_page": "background.html",
 
"browser_action":
 
{
     
"default_icon": "icon.png"
 
},
 
"permissions" : [
   
"tabs"
 
]
}

This is the background.html

<html>
 
<head>
   
<script>
 //Supposed to Called when the user clicks on the browser action icon.
  chrome.browserAction.onClicked.addListener(function(tab)
    {
               console.log('I am clicked');
   
}
   
);

   
</script>
 
</head>
</html>

i opened the java script console in chrome and then clicked on the browser action icon but nothing was written on the console. 

I believe the event handler is not getting called or not getting registered.

Please advise


Thanks

Prerak K.






--
Thanks and regards
Prerak Kaushik

Finnur Thorarinsson

unread,
Oct 29, 2010, 5:28:35 AM10/29/10
to Prerak Kaushik, chromium-...@chromium.org
It all looks good to me. I suspect the problem is that you are opening the console to inspect the web page and not the background page. Try this:

Go to chrome://extensions
Make sure the Developer Mode section is expanded
Find your extensions
Click the background.html link within it.

Then press the browser action button again. I'm sure it will now trigger the log to appear.


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Reply all
Reply to author
Forward
0 new messages