Hello, The code you pasted is a bookmarklet, as in, you add a bookmark and place its URL to: "javascript:(function(){m=' http://mail.google.com/mail/?ui=1&view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(document.location);w=window.open(m,'addwindow ','status=no,toolbar=no,width=575,height=545,resizable=yes');setTimeout(function(){w.focus();},%20250);})();"
As far as I know, it will not work in an extension because each extension has is its own page. You will get the chrome-extension://000000000000000000000000000000000/tool_strip.html as its document.location (aboodman can correct me if I am wrong). If you wanted to make that as an extension. You would have to use the chrome API's. I don't believe the Tabs API ( http://dev.chromium.org/developers/design-documents/extensions/tabs-api) is complete. So you have to get the current window id and use that id to get the current working tab. Something like this: function getCurrentWindowTitle() { chrome.windows.getCurrent(onCurrentWindow); } function onCurrentWindow(currWindow) { chrome.tabs.getSelected(windowID, onSelectedTab); } function onSelectedTab(currTab) { var tabURL = currTab.url; } I believe you can go directly and get the selected tab by doing: chrome.tabs.getSelected(onSelectedTab); But, getSelected for the Tabs API is not currently implemented (or not working, for me that is). Aboodman can clarify. -- Mohamed Mansour On Sun, May 31, 2009 at 7:57 PM, Zak <zakk...@gmail.com> wrote: > > Hi, > > I'm really not a coding person, but I followed the documentation > here: > > http://dev.chromium.org/developers/design-documents/extensions/howto > > and set up an extension. Instead of hello-world.html I put an html > file containing a script (a gmail-this-page bookmarklet). The code is > below: > > [code] > javascript:(function(){m='http://mail.google.com/mail/? > ui=1&view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(document.title)<http://mail.google.com/mail/?%0Aui=1&view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(document.title)> > +'&body='+encodeURIComponent(document.location);w=window.open > > (m,'addwindow','status=no,toolbar=no,width=575,height=545,resizable=yes');setTimeout > (function(){w.focus();},%20250);})(); > [/code] > > When I click the extension on the bottom bar, it just opens up an html > page with that code written in plain text. Obviously I'm missing some > crucial step, and since I don't have a background in coding or > programming of any sort, I'm pretty lost. Evidently putting the > javascript in an html file is a wrong move - a different filetype > maybe? > > Thanks. And ignore me if I'm wasting your time or whatever, I realize > I'm some newbie guy asking probably a dumb question, but I'd > appreciate any help getting this simple thing working. > > > > --~--~---------~--~----~------------~-------~--~----~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---