Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 2 of 2

This is a discussion on my first extension - add bookmark with a click - HOW TO? within the Chrome Tech section, part of the Chrome Chat category: I am learning to write javascript and chrome extension. I want an extension that will show a button, and on ...


  1. #1
    deckoff is offline Junior Member
    Join Date
    Aug 2011
    Posts
    2

    Default my first extension - add bookmark with a click - HOW TO?

    I am learning to write javascript and chrome extension. I want an extension that will show a button, and on a click it will add a bookmark folder in the bookmarks. So far so good, got the button, but clicking it adds nothing.
    I suppose my javascript is not correct:
    here is the code
    manifest:
    Code:
    {
      "name": "My First Extension",
      "version": "1.0",
      "background_page": "background.html",
      "permissions": [
        "tabs", "http://*/*", "bookmarks"
      ],
      "browser_action": {
          "default_icon": "icon.png",
          "name": "HELLO WORLD"
      }
    }
    Code:
    background.html
    
    <html>
    <head>
    <script>
    
    
      function updateIcon() {
        chrome.bookmarks.create({parentId: bookmarkBar.id,
                             title: 'Extension bookmarks'});
                      } 
    
    
      chrome.browserAction.onClicked.addListener(updateIcon);
      updateIcon();
    
    
    
    
    );
    </script>
    </head>
    </html>
    I suppose it is
    Code:
      function updateIcon() {    chrome.bookmarks.create({parentId: bookmarkBar.id,
                             title: 'Extension bookmarks'});
                      }
    that is wrong.
    Please, advice me and any ggod places for learning javascript. I have read http://code.google.com/chrome/extensions/bookmarks.html already
    Last edited by deckoff; 08-05-2011 at 12:14 PM.

  2. #2
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    656

    Default

    In updateIcon you use bookmarkBar.id but its never defined. Incase your wondering the id for the bookmarks bar is always 1 so you could replace the bookmarkBar.id with 1.

    Some good links for info on JS are......
    https://developer.mozilla.org/en/JavaScript/Guide
    http://blog.reybango.com/2010/12/15/what-to-read-to-get-up-to-speed-in-javascript/

    http://bonsaiden.github.com/JavaScript-Garden/
    http://www.quirksmode.org/js/contents.html

Similar Threads

  1. Replies: 0
    Last Post: 03-31-2011, 07:35 AM
  2. change double click context menu to single click.
    By bmorency in forum Chrome Troubleshooting
    Replies: 0
    Last Post: 07-25-2010, 01:08 AM
  3. Replies: 14
    Last Post: 01-27-2010, 12:52 PM
  4. Right click a Browser Action Extension
    By Luc VN in forum Chrome Talk
    Replies: 7
    Last Post: 01-14-2010, 10:28 PM

Posting Permissions

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