Page 1 of 2 12 LastLast
Results 1 to 10 of 12

This is a discussion on Help! Why doesn't this work? within the Plugins Development section, part of the Chrome Plugins category: I was recently trying to make a simple extension, following the chromium documentation page. it was a hello world button ...


  1. #1
    SifJar is offline Senior Member
    Join Date
    May 2009
    Posts
    99

    Default Help! Why doesn't this work?

    I was recently trying to make a simple extension, following the chromium documentation page. it was a hello world button which loaded a file hello_world.html. What i did was modify it to load chrome://extensions instead, but it only opens a blank tab. if i changed it to open google, it worked fine, but not chrome://extensions. Anyone tell me why? Is there a way to make it work?

  2. #2
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Haven't tried to reproduce this but here are some ideas..

    Copy pasting your code might help us spot the problem.
    Try " chrome://extensions/ " instead of " chrome://extensions " (Note the trailing '/')
    The blank tab that is opened, does it have a URL ? What if you do in the javascript console (CTRL+SHIFT+J) window.location.href ?

  3. #3
    SifJar is offline Senior Member
    Join Date
    May 2009
    Posts
    99

    Default

    ok, i already had the trailing slash there, makes no difference. in the address bar and upon typing window.location.href into javascript console both give the address as about:blank (i.e. a blank page). However, when i open javascript console, i notice it says "not allowed to load local resource: chrome://extensions/

    looks like extensions can't open this page, unless there's a way around it you or someone else know of?

  4. #4
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Ok, it seems that chrome://extensions/ is a special page that cannot be accessed through javascript.

    Open any webpage and in the console type "window.open('chrome://extensions/')" and it will open a 404 page.
    However, pressing enter in the omnibar with the exact same url will work.

    Can you try using chrome.tabs ?

  5. #5
    SifJar is offline Senior Member
    Join Date
    May 2009
    Posts
    99

    Default

    i'm sorry, what do you mean "using chrome.tabs"? i'm a bit of a n00b when it comes to programming. tried a firefox extension but it was complicated so gave. this seems easier but perhaps not.

  6. #6
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    You can see the API here : http://dev.chromium.org/developers/d...sions/tabs-api

    There is an example in the sample extensions on how to do it.

    Here is an example:
    chrome.tabs.createTab({url:"http://www.gmail.com/"});

  7. #7
    SifJar is offline Senior Member
    Join Date
    May 2009
    Posts
    99

    Default

    and i should use "chrome://extensions/" where "http://www.gmail.com/" is in your example?

  8. #8
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Sorry, i can't help you on this one

    You should check the documentation.. I haven't had the chance to read it or to use the tabs API yet.

  9. #9
    SifJar is offline Senior Member
    Join Date
    May 2009
    Posts
    99

    Default

    well i have no idea what to do with that, where to put that line you wrote etc. like i said, total n00b. ah well, guess i wont be making that extension after all.

  10. #10
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Now now.. you can't give up like that

    In order to create an extension, you need at least some basic knowledge of javascript.

    Googling javascript turorial would be a good start.
    The w3c schools website is also an excellent ressource.

    Then when you are familiar enough with javascript, you can start working on Chrome extensions. These are all made using javascript / html.

    In order to enable more advanced and specific features for extensions, Chrome has several Objects that can be used.

    The "tabs" object is one of them. It allows you to create tabs among other useful things.

    --

    On your button, you probably have a onclick="DOSOMETHING()"

    "onclick" is an event that is fired every time the button is clicked. When it is clicked, it will execute DOSOMETHING().

    In your helloworld, window.open('helloworld.html')

    You can replace this with a function you made yourself
    Code:
    <button onclick="myFunction()">Hello!</button>
    
    <script>
    function myFunction(){
    
    // ADD LOGIC AND STUFF HERE
    
    }
    </script>
    You can then replace " // ADD LOGIC AND STUFF HERE " with whatever you want.
    I suggested "chrome.tabs.createTab({url:"http://www.gmail.com/"});"
    I am not certain however that this is the right syntax since they recently changed it.

    It might be "chromium.tabs.createTab({url:"http://www.gmail.com/"});"
    or "chrome.tabs.create({url:"http://www.gmail.com/"});"

    The parameter to the createTabs function is a JSON (you can read more about this here http://www.json.org/). You specify which URL the tab should use, in your exemple :
    Code:
    {url:"chrome://extensions/"}

    This is pretty much all I can tell you. The best way to learn is to try it yourself !

    Good luck
    Last edited by Kyrax; 05-16-2009 at 07:41 PM. Reason: typo

Page 1 of 2 12 LastLast

Similar Threads

  1. Sites that won't work with Chrome
    By lnw in forum Bugs and Vulnerabilities
    Replies: 7
    Last Post: 10-21-2011, 06:22 PM
  2. Windows buttons don't work in Chrome
    By cappyq in forum Bugs and Vulnerabilities
    Replies: 10
    Last Post: 06-16-2010, 02:07 PM
  3. hotmail does not work on chrome
    By sam2 in forum Bugs and Vulnerabilities
    Replies: 12
    Last Post: 08-12-2009, 08:01 PM
  4. Gravity at Work
    By ducktape in forum General Chat
    Replies: 3
    Last Post: 04-10-2009, 07:18 PM
  5. Themes won't work with 0.3 update
    By Cerbera in forum Themes Troubleshooting
    Replies: 2
    Last Post: 11-30-2008, 10:55 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
  •