2010-09-09 25 views
1

這個工作正常browserAction .. 但是當我打開它pageAction ..連圖標亙古不顯示鉻browserAction到pageAction

background.html

<html> 
    <head> 
    <script> 
     // Called when the user clicks on the browser action. 
     chrome.browserAction.onClicked.addListener(function(tab) { 
     chrome.tabs.create({'url':'http://google.com/search?q=site:'+window.location.host}); 
     }); 

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

的manifest.json

{ 
    "name": "linkcheck", 
    "description": "check link.", 
    "version": "1.1.1", 
    " 

background_page": "background.html", 
    "permissions": ["tabs", "http://*/*","https://*/*"], 
    "browser_action": { 
    "name": "linkcheck", 
    "default_icon": "icon.png" 
    }, 
    "icons": { 
     "128": "icon128.png", 
     "48": "icon48.png"    
    }, 

    "content_scripts": [ 
    { 
     "matches": ["https://www.google.com/*"], 
     "js": ["myscript.js"], 
     "run_at": "document_end" 
    } 
    ] 
} 

回答

0

那麼對於pageAction,您需要輸入另一個清單property

{ 
    "name": "My extension", 
    ... 
    "page_action": { 
    "default_icon": "icons/foo.png", // required 
    "default_title": "Do action", // optional; shown in tooltip 
    "default_popup": "popup.html" // optional 
    }, 
    ... 
} 

然後您需要hideshow

chrome.pageAction.show(integer tabId)