Other APIs
Other APIs
In addition to the
chrome.* APIs,
extensions can use all the APIs
that the browser provides
to web pages and apps.
If the browser doesn't support an API you want to use,
you can bundle additional API libraries into your extension.
Here's a sampling of the APIs that extensions can use:
- Standard JavaScript APIs
- These are the same core JavaScript and
Document Object Model
(DOM) APIs
that you can use in ordinary web apps.
- XMLHttpRequest
-
Use XMLHttpRequest
to request data from one or more servers.
The permissions field
of the manifest specifies
which hosts the extension can send requests to.
- WebKit APIs
-
Because Google Chrome is built upon WebKit,
your extensions can use WebKit APIs.
Especially useful are the experimental CSS features
such as filters, animations, and transformations.
Here's an example of using WebKit styles
to make the UI spin:
<style>
div:hover {
-webkit-transform: rotate(360deg);
-webkit-transition: all 1s ease-out;
}
</style>
- V8 APIs, such as JSON
- Because JSON is in V8, you don't need to include a JSON library to use JSON functions.
- HTML5 APIs, such as localStorage
- HTML5 is still being defined and implemented,
but Google Chrome already supports local storage,
which extensions can use to store data.
- APIs in bundled libraries
- If you want to use a library that the browser doesn't provide
(for example, jQuery),
you can bundle that library's JavaScript files with your extension.
Bundled libraries work in extensions
just as they would in any other web pages.
API reference: chrome.apiname
Properties
getLastError
chrome.extensionlastError
Methods
method name
void
chrome.module.methodName(,
)
Undocumented.
A description from the json schema def of the function goes here.
Parameters
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Type param1, Type param2) {...});
Events
event name
chrome.bookmarksonEvent.addListener(function(Type param1, Type param2) {...});
Undocumented.
A description from the json schema def of the event goes here.
Parameters