The first parameter has no key named 'stackoverflow.com '. I think
you are trying to search for history items which include
'stackoverflow.com ', in which case you want something like this:
chrome.history.search( { text: "stackoverflow.com" }, function(historyItems) {
console.log("Got some history items");
});
console.log is a better choice than alert() for extension API
callbacks, because it doesn't block. See
http://code.google.com/chrome/extensions/tut_debugging.html for more
information on tools that can help you debug.
Sam
>
> We have also added the permissions in the JSON script.
> It does not alert the message which means there is an error in the syntax of
> search.
>
> Regards,
> Jyothsna
>
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to chromium-...@chromium.org.
> To unsubscribe from this group, send email to
> chromium-extens...@chromium.org.
> For more options, visit this group at
> http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
Jyothsna,
I re-added the chrome extensions mailing list. When asking about
development issues, please keep the mailing list CCed. This has two
benefits. First, you are likely to get a better answer if a wider
audience sees your question. Second, the next person who runs into
the same issue will be able to find this discussion using a search
engine.
> content scripts has the name of the file myjs.js whose code should be
> activated when URL is entered.
> These are the exceptions I am getting
>
> Uncaught Error: "search" can only be used in extension processes. See the
> content scripts documentation for more details.
I think you are trying to use the chrome history API from a content
script. Content scripts can't use most extension APIs, including the
history API. You will need to create a background page, and have
javascript in the background page call the history API. See
http://code.google.com/chrome/extensions/background_pages.html for
information.
Content scripts give access to the DOM of a page. If you don't need
that, you might be able to write all your code in a background page.
If you do need DOM access, you will need to communicate between your
content script and your background page. See
http://code.google.com/chrome/extensions/messaging.html for an
explanation of how to do this.
Sam
If you are seeing the alert with "msg sent", then you got a response.
The second parameter to the function chrome.extension.sendRequest() is
a callback. This callback is run only when a response is received.
If a response was recieved, than it must have been sent, so I bet your
background page called sendResponse(). I think background pages do
not run alert(), so you will never see alert("msg recvd"); even if
your code works.
Try changing alert("msg sent"); to alert("Got a response: " +
JSON.stringify(response, null, 2)); to see the value of the response
parameter. I think you will find that response is the object you
passed to sendResponse: { farewell: "received" }.
If you want to see what the background page is doing, console.log() is
generally a better choice than alert(), because it works consistently
in tabs, popups, background pages, and so on.
Sam
On Mon, Apr 9, 2012 at 5:20 PM, jyothsna iyer <angel....@gmail.com> wrote:
Is the background page loading? If you go to chrome://extensions,
make sure the "Developer Mode" checkbox is checked, and click the
small grey triangle to the left of your extension, you should see a
list of active views. Is there a link to popup.html ?
If so, click it to open the debugger on your background page. Are
there any errors in the code that prevented the javascript code "
chrome.extension.onRequest.addListener( ..." from running?