Tabris implements a subset of popular W3C standards. Besides providing web developers with familiar APIs, this also enables you to use libraries developed for a browser environment.
global is the actual global object in Tabris.js. For example, the tabris object can be accessed either via
As in the browser, messages can be logged to the developer console using the global
console.log("A log message"); console.warn("A warning message"); console.error("An error Message"); console.trace();
console.error will also cause a message to pop up (even if the developer console is closed), but it won’t interrupt script execution. See Console.
Tabris supports the timer methods
clearInterval. See timer.
Tabris supports the Fetch API to make HTTP request and to read resources that are part of the application.
When a relative URL is given, Tabris.js will interpret it as a path relative to the application’s main
package.json. This allows you to read static resources, i.e. the files residing in your project folder and not excluded via
.tabrisignore. You can also use URLs relative to the current module by using the
__dirname variable, e.g.
fetch(__dirname + "/foo.txt");.
To enable access to SSL protected resources that use self signed certificates add them to
app.trustedCertificates. Alternatively you can disable the
UseStrictSSLpreference in the config.xml to accept all certificates. See Building a Tabris.js App.
Blobs represent raw data that may be created from various sources and can also be read into an
ArrayBuffer or converted to a string. They are accepted by fetch, XMLHttpRequest, FileSystem and WebSocket APIs.
Tabris also supports
fetch() is recommended for convenience.
Only asynchronous requests are supported in Tabris.js. Attempting a synchronous request will cause an error.
WebSockets are an advanced technology that makes it possible to open an interactive communication session between the user’s client and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
The Tabris.js implementation supports to send and receive text messages as well as binary data in the form of
ArrayBuffer, but not
The tabris support for workers allows to send data to a running worker via the
worker.postMessage(data, transferList) method. The
transferList is ignored. The types supported in the data field are:
Only the following Tabris.js APIs can be used in a worker:
- App (Except:
- file system
Widget APIs are unavailable. Calling any unsupported APIs has no effect.
Tabris supports the global object
localStorage, which allows storing key-value pairs in a persistent store. Both keys and values are stored as strings. See also localStorage.
Note that the “storage” event is not supported. For debugging purposes the contents of the localStorage can be inspected using
console.dirxml()[./api/console.md#dirxml]. On iOS, there is an additional object
secureStorage available in the global scope. This is a drop-in replacement for
localStorage that keeps data in the encrypted iOS Keychain.
localStorageis only meant to store relatively short strings. To store larger amounts of data it is recommended to use the cordova
Canvas widget provides an HTML5 canvas compatible “2D Context” object. See Canvas.
Random Source (Crypto)
The global object
crypto provides an implementation of the RandomSource interface. It can be used to generate cryptographically secure random numbers.