Three new JavaScript APIs you might want to use

Source: Internet
Author: User
If you are a SitePoint old readers and are my fans then you already know I wrote a lot about HTML5 as well JS API the article. So far, I've posted some introductions that you can use right now. API , although it may be possible to use Polyfill the way. Do not know what is Polyfill please click here. )

But today I might break this routine to introduce you to some of the things that are still in the early stages. API . You have to know that these APIs are very new, and that two of these three are just released a few days ago. Because of this, these APIs are now unusable. But if you are interested in knowing exactly what they are for, you can continue to read the detailed descriptions below, and also welcome your comments and responses.

Don't say much nonsense, start now!

Web Alarms API

Web Alarms API lets you configure the device's alarm settings so that you can schedule notification messages or allow a specific app to start at a specified point in time. The Most typical usage of this API involves things like an alarm clock, a calendar, or any other program that requires a specific action at a specific time.

since the beginning of last year, this API Has just become a the the draft design. So all The details needed to become official recommendations are still in its infancy. This API needs to be used by the alarms property under the window.navigator object . the Alarms Property provides three functions:

getAll (): get all existing alarms from the device and include Alarm returns an array of objects.

Add (): register for one based on Date object's alarm and returns a alarmrequest object.

Remove (): through Unique ID remove a previously registered alarm (uniqueness only applies to the app itself)

To show you how these functions should be used in an ideal situation, here's an example of adding an alarm (please remember that this code is not supported by any browser currently)

View Sourceprint?

var Alarmid;

var request = Navigator.alarms.add (

New Date ("June 29, 2012 07:30:00"),

"Respecttimezone",

);

request.onsuccess = function (e) {

Alarmid = E.target.result;

};

Request.onerror = function (e) {

alert (e.target.error.name);

};

If you want to learn more about Web Alarms API , please refer to the relevant details documentation.

Presentation API

Presentation API The goal is to have the projector or TV such a second display device can be Web use, including all through Wired ( HDMI , DVI and other) connections and via Wireless ( MiraCast, Chromecast, DLNA, AirPlay , etc.) of the device. What this API does is to implement message interoperability between the request page and the presentation page on the second display device.

Please note that the API details do not belong to the Standard, also not the Standard Plan. This API needs to be used by the presentation property under the window.navigator object . This property provides a function called requestsession () , as well as present and Availablechange two of events. the requestsession () function can be used to start or resume a demo on a second display device. It returns a session object that refers to the current presentation. When the demo content in the URL passed in via requestsession () is loaded, the page of the presentation screen will receive Present event. Finally, the Availablechange event is emitted after the first presentation appears or when the last presentation is complete .

For example, from a detail document, the API the usage is as follows:

View Sourceprint?

Show

If you want to learn more about Presentation API message, you can look at the final report.

Standby API

Standby API allows you to request a continuous display lock on the screen in the top-level browser page. This prevents the device from entering the power saving state (for example, the screen automatically shuts down). This feature is critical for some Web applications. For example, imagine that you are driving and using Web -based navigation software (not local apps) on your phone. If you don't touch the screen, your phone's screen will automatically turn off, unless you've previously set it up on your phone. In such cases, you usually want to keep the screen in the display state. This is exactly where this API applies.

this API need to pass Window.navigator object under the WakeLock property to use. It will provide two functions:

request (): enables the current app to keep the screen in the display state.

release (): Release the persistent display lock so that the screen is no longer required to be displayed.

Both of these functions accept only one parameter, which can only be " Screen "or" system ". The former indicates that the action is for the device screen, which is for other device resources, such as CPU or broadcast, other than the screen.

The following example shows how to apply the API Keep the device screen in the display state:

View Sourceprint?

Navigator.wakeLock.request ("Display"). Then (

function Successfunction () {

Do something

},

function Errorfunction () {

Do something else

}

);

To let the device allow the screen to close, we can use the following methods:

View Sourceprint?

Navigator.wakeLock.release ("display");

If you want to learn more about Standby API For more information, refer to this unofficial draft.

Summarize

in this article I have introduced some brand-new JS API . I would like to emphasize again because they are still in a very early stage, so there is no browser support at this time. So we can't actually manipulate them. But just because they're so new, everyone has a chance to follow up on their next developments and even participate in the refinement of their detailed design.

Free pick up LAMP brother Lian Original PHP Tutorials CD / the About PHP "Essentials Edition, details of the consultation website customer service: http://www.lampbrother.net

Phpcms Two-time development http://yun.itxdl.cn/online/phpcms/index.php?u=5

Development http://yun.itxdl.cn/online/weixin/index.php?u=5

Mobile Internet server-side development http://yun.itxdl.cn/online/server/index.php?u=5

Javascript Courses http://yun.itxdl.cn/online/js/index.php?u=5

CTO Training Camp http://yun.itxdl.cn/online/cto/index.php?u=5

Here are some of the three new JavaScript APIs you might want to use, including content that you want to help your friends who are interested in PHP tutorials.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.