Search code examples
google-chromegoogle-chrome-extension

Open a "Help" page after Chrome extension is installed first time


I am new to Chrome extension. I have a question about how to make the extension to open a "Help" page automatically after installation. Currently, I am able to check whether the extension is running the first time or not by saving a value into localStorage. But this checking is only carried out when using click the icon on the tool bar. Just wondering if there is a way that likes FF extension which uses the javascript in to open a help page after the installation. Thanks.

Edit: Thanks for the answer from davgothic. I have solved this problem. I have another question about the popup. My extension checks the url of current tab,

if OK(url){
    //open a tab and do something
}
else{
    //display popup
}
Is it possible to show the popup in this way?


Solution

  • UPDATE: This method is no longer recommended. Please see Nuhil's more recent answer below.

    I believe what you need to do is put something like this into a script in the <head> section of your extension's background page, e.g. background.html

    function install_notice() {
        if (localStorage.getItem('install_time'))
            return;
    
        var now = new Date().getTime();
        localStorage.setItem('install_time', now);
        chrome.tabs.create({url: "installed.html"});
    }
    install_notice();