Results 1 to 2 of 2

This is a discussion on Page Action addListener gives error. within the Plugins Troubleshooting section, part of the Chrome Plugins category: I am writing a simple page action extension that is displayed for every tab and simple writes something to the ...


  1. #1
    rajesh.poddar is offline Junior Member
    Join Date
    Aug 2009
    Posts
    1

    Default Page Action addListener gives error.

    I am writing a simple page action extension that is displayed for every tab and simple writes something to the console upon executing. However, I get the following error in the javascript debugger - "Uncaught TypeError: Cannot call method 'addListener' of undefined". I can't figure out why this is happening.

    My manifest.json is:

    Code:
    {
      "background_page": "enable.html",
      "name": "HUL Redirect Extension",
      "version": "1.0",
      "description": "Extension for redirecting through HUL Proxy",
      "page_actions": [ {
         "id": "hulredirect",
         "icons": ["RedirectIcon.png"],
         "name": "HUL Redirect"
      } ]
    }
    and my enable.html is:

    Code:
    <html>
    <head>
        <script type="text/javascript">
            chrome.tabs.onUpdated.addListener(function(tabid) {
                chrome.tabs.get(tabid, function(currentTab) {
                        chrome.pageActions.enableForTab('hulredirect', {
                            tabId: currentTab.id,
                            url: currentTab.url,
                            title: "HUL Redirect",
                            iconId: 0
                        });
    		 });
    	  });
    
            chrome.pageActions["hulredirect"].addListener(function(pageaction) {
    		  console.log("Test");
            });
    
        </script>
    </head>
    <body>
    </body>
    </html>
    Any help would be greatly appreciated.

    Thanks,
    Rajesh

  2. #2
    nemrod's Avatar
    nemrod is offline Member
    Join Date
    Aug 2009
    Location
    Sweden
    Posts
    34

    Default

    I'm also having a problem with page actions, difference is I don't even get an error. The page action shows up in the omnibox but when clicked nothing happens.

    manifest.json
    Code:
    {
    	"name": "Page Action Test",
    	"version": "1.0",
    	"description": "Testing Page Actions.",
    	"background_page": "background.html",
    	"page_actions": [{
    		"id": "myaction",
    		"name": "Page Action",
    		"icons": ["favicon.ico"]
    	}]
    }
    background.html
    Code:
    <script type='text/javascript'>
    chrome.tabs.onUpdated.addListener(function(tabId, chprops) {
    	chrome.tabs.getSelected(null, function(tab) {
    		chrome.pageActions.enableForTab("myaction", {
    			tabId: tab.id,
    			url: tab.url,
    			title: tab.url,
    			iconId: 0
    		});
    	});
    });
    chrome.pageActions["myaction"].addListener(function(details) {
    	var tabId = details.data.tabId;
    	var tabUrl = details.data.tabUrl;
    	chrome.tabs.get(tabId, function(tab) { // this or anything else I've tried isn't happening
    		chrome.tabs.create({url:tabUrl,index:tab.index+1});
    	});
    });
    </script>
    The code is pretty much identical. I wonder why I'm not getting anything at all while you're getting an error. :/

    edit:
    Quote Originally Posted by PAEz View Post
    Might be a bug in Chrome...I just tried the RSS sample and its not opening the subscribe page which Im sure its meant to (never used it before).
    http://dev.chromium.org/developers/d...nsions/samples
    I think he's right, when the "official" sample isn't working it's definitely broken somewhere.

    edit2:
    http://code.google.com/p/chromium/is...etail?id=18240
    Last edited by nemrod; 08-11-2009 at 06:53 AM.

Similar Threads

  1. Page Action development problems :x
    By henasraf in forum Plugins Development
    Replies: 7
    Last Post: 08-17-2009, 07:03 PM
  2. Google Bookmarks Page Action
    By Wossname in forum Chrome Plugins
    Replies: 6
    Last Post: 08-11-2009, 10:18 PM
  3. Subscribe as a page action
    By rock_galore in forum Chrome Plugins
    Replies: 19
    Last Post: 06-23-2009, 04:27 PM
  4. Replies: 0
    Last Post: 06-18-2009, 06:11 PM
  5. Replies: 1
    Last Post: 03-14-2009, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •