Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7457827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:22:20+00:00 2026-05-29T13:22:20+00:00

I was playing around with some chrome extensions and I found this example: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_url/

  • 0

I was playing around with some chrome extensions and I found this example:http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_url/

Everything works fine, but I want to create my own extension and I want to see the page_action Icon on a specific site, not ones with ‘g’ in their urls.
So I tried simply to change the script from this:

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Called when the url of a tab changes.
function checkForValidUrl(tabId, changeInfo, tab) {
// If the letter 'g' is found in the tab's URL...
if (tab.url.indexOf('g') > -1) {
// ... show the page action.
chrome.pageAction.show(tabId);
}
};

// Listen for any changes to the URL of any tab.
chrome.tabs.onUpdated.addListener(checkForValidUrl);

Into this:

chrome.pageAction.show(tabId);

But now it doesn’t work…
I don’t get it. Obviously I can use a workaround, but that’s not the point… First of all, must I create a background page to do this? I think yes but I can’t see why, and why the .show method doesn’t work alone?
I tried to search in the google documentation and stuff, but I couldn’t find anything useful I’m no expert and this has been my first afternoon spent on google extension, but how should I know that the “chrome.page.show(tabId)” must go in a background page if it’s not written anywhere? No intent to criticize, but how the hell did you guys find out? All chrome methods must go in a background page?
Well, definitely much more questions then what its legit. Hope you can give me at least one answer!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:22:20+00:00Added an answer on May 29, 2026 at 1:22 pm

    http://code.google.com/chrome/extensions/pageAction.html
    …says…

    By default, a page action is hidden. When you show it, you specify the
    tab in which the icon should appear. The icon remains visible until
    the tab is closed or starts displaying a different URL (because the
    user clicks a link, for example).

    So even if your tabid was valid it would dissapear pretty quick as your only running chrome.pageAction.show(tabId); once when the background page first gets run.
    You need to check for changes to tabs in the background constantly because pageactions dont have matches/exclude_matches settings in the manifest like content scripts do (pity). So you have to check yourself and respond to changes.
    If you want it to work for a specific site just change it to something like…

    // Copyright (c) 2011 The Chromium Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    
    // Called when the url of a tab changes.
    function checkForValidUrl(tabId, changeInfo, tab) {
        // If the tabs url starts with "http://specificsite.com"...
        if (tab.url.indexOf('http://specificsite.com') == 0) {
            // ... show the page action.
            chrome.pageAction.show(tabId);
        }
    };
    
    // Listen for any changes to the URL of any tab.
    chrome.tabs.onUpdated.addListener(checkForValidUrl);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was playing around with some JavaScript code and found that when I took
I'm playing around with some HTML5 elements, and ran into a fun behavior. This
I'm playing around with some APIs and I'm trying to figure this out. I
I am playing around with some recursion, and trying to count the number of
I'm playing around with some Dependency Injection ( StructureMap ) with my ASP.NET MVC
I'm playing around with some historical data wherein some dates I know accurately (i.e.
I'm playing around with writing some simple Spring-based web apps and deploying them to
I am trying to set up an Android emulator to do some playing around
Here is some C++ code I'm playing around with: #include <iostream> #include <vector> #define
I was playing around with my own Sudoku solver and was looking for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.