


html5 desktop reminder: Notifycations application introduction_html5 tutorial skills
Desktop reminders (web notifications) in HTML5 can pop up a message box in the current page window. This message box spans tab windows. This makes the reminder more convenient and easy for users to see when the user opens multiple tabs to browse the web. Currently, only the webkit kernel supports this feature.
This feature needs to be opened in http mode in chrome to enable it.
The desktop reminder function is implemented by the window.webkitNotifications object (webkit kernel).
The window.webkitNotifications object has no attributes and has four methods:
1.requestPermission()
This method is used to apply for message reminder permission from the user. If this permission is not currently open, The browser will pop up the authorization interface. After the user authorizes, a status value (an integer of 0, 1 or 2) is generated inside the object:
0: Indicates that the user agrees to the message reminder, and the message reminder function can only be used in this state. ;
1: Indicates the default state, the user neither rejects nor agrees;
2: Indicates that the user rejects the message reminder.
2.checkPermission()
This method is used to obtain the status value of the permission applied for by requestPermission().
3.createNotification()
This method creates a reminder message as a pure message. It accepts three string parameters:
iconURL: the icon address displayed in the message,
title: the title of the message,
body: the text content of the message body
This method will return a Notification object, and more settings can be made for this object.
Attributes and methods of Notification object:
dir: ""
onclick: null
onclose: null
ondisplay: function (event) {
onerror: null
onshow: null
replaceId: ""
tag : ""
__proto__: Notification
addEventListener: function addEventListener() { [native code] }
cancel: function cancel() { [native code] }
close: function close() { [ native code] }
constructor: function Notification() { [native code] }
dispatchEvent: function dispatchEvent() { [native code] }
removeEventListener: function removeEventListener() { [native code] }
show: function show() { [native code] }
__proto__: Object
dir: Set the arrangement direction of messages. The possible values are "auto" (automatic), "ltr "(left to right), "rtl"(right to left).
Tag: Add a tag name to the message. If this attribute is set, when there is a new message reminder, messages with the same label will only be displayed in the same message box, and the latter message box will replace the previous one. Otherwise, multiple message prompt boxes will appear, but a maximum of 3 message boxes will be displayed. If there are more than 3, subsequent message notifications will be blocked.
onshow: This event is triggered when the message box is displayed;
onclick: This event is triggered when the message box is clicked;
onclose: This event is triggered when the message is closed;
onerror: When This event is triggered when an error occurs;
Methods:
addEventListener && removeEventListener: conventional methods to add and remove events;
show: display the message reminder box;
close: close the message reminder box;
Cancel: Close the message reminder box, the same as close;
4.createHTMLNotification()
This method is different from createNotification() in that it creates the message in HTML and accepts one parameter : The URL of the HTML file. This method also returns the Notification object.
An example:

H5 improves web user experience with multimedia support, offline storage and performance optimization. 1) Multimedia support: H5 and elements simplify development and improve user experience. 2) Offline storage: WebStorage and IndexedDB allow offline use to improve the experience. 3) Performance optimization: WebWorkers and elements optimize performance to reduce bandwidth consumption.

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.