Dans ce tutorial JavaScript, nous sommes ensemble pour profiter des exp?riences impressionnantes sur HTML5 avec les nouvelles API JavaScript chaude Avec beaucoup de JavaScript/d?mos d'applications Web en direct dans ce HTML5 JavaScript tutorial, nous pouvons apprendre:
? JavaScript s?lecteurs CSS, s?lecteurs jQuery pour s?lectionner les ?l?ments HTML mieux - Nouvelle fonction de stockage Web et des nouvelles de stockage Web base de donn?es SQL - Nouvelle API pour la mise en cache de donn?es hors application, cache des fichiers JavaScript - Comment utiliser les travailleurs Web et prises de courant sur le Web - API de g?olocalisation - Audio, vid?o et manipulation Toile sur HTML5.
- Demo
- Agrandir
- Recharger
- New window
Gratuit iPage h�bergement Web pour la premi�re ann�e MOMENT
Si vous �tes toujours � la recherche d'un fournisseur d'h�bergement Web fiable avec des tarifs abordables, pourquoi vous ne prenez pas un peu de temps pour essayer iPage, seulement avec $1.89/month, inclus $500+ Cr�dits suppl�mentaires gratuites pour le paiement de 24 mois ($45)?
Plus de 1.000.000 de clients + existisng peuvent pas avoir tort, vraiment vous n'�tes pas aussi! Plus important encore, lorsque vous enregistrez l'h�bergement web � iPage gr�ce � notre lien, nous allons �tre heureux de renvoyer un plein remboursement. C'est g�nial! Vous devriez essayer iPage h�bergement web GRATUITEMENT maintenant! Et contactez-nous pour tout ce que vous devez savoir sur iPage.
Web workers
Workers are API for running scripts in the background independently of any user interface scripts. Generally, workers are expected to be long-lived, have a high start-up performance cost, and a high per-instance memory cost. Moreover they might be partially replaced by window.setTimeout() function. So have they any advantages? Yes, of course.
- workers are separate JS processes () running in separate threads,
- workers execute concurrently,
- workers don't block the UI,
- workers allow you to extract up to the last drop of juice from a multicore CPU,
- workers can be dedicated (single tab) or shared among tabs/windows,
- workers can be persistent too (coming soon): they'll keep running after the browser has quit.
If we call function by setTimeout, the execution of script and UI are suspended. When we call function in worker, it doesn't affect UI and execution flow in any way. Enough said.
To create Worker, we put JavaScript in separate file and create new Worker instance:
var worker = new Worker('extra_work.js');
That's it. We can communicate with worker using postMessage function and onmessage listener. Messages are sended to all threads in our application:
main.js:
var worker = new Worker('extra_work.js');
worker.onmessage = function (event) { alert(event.data); };
extra_work.js:
// do some work; when done post message.
// some_data could be string, array, object etc.
postMessage(some_data);
There are also so called Shared Workers. Thay use slightly different APIs, since each worker can have multiple connections. An example purpose is logger or application manager. If you are intrested follow fakeworker-js from Google Code.
See demo using workers and similar one without them (will hang your browser).
Web sockets
Let me quote Chromium Blog:
----
Web Sockets are "TCP for the Web," a next-generation bidirectional communication technology for web applications. They allow a web server to push data to a browser (COMET). Developers have been using XMLHttpRequest (known as persistent Ajax connection) for such purposes, but XHR makes developing web applications that communicate back and forth to the server unnecessarily complex.
Web Sockets provide a real bidirectional communication channel in your browser. Once you get a Web Socket connection, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler. A simple example is included below.
if ("WebSocket" in window) {
var ws = new WebSocket("ws://example.com/service");
ws.onopen = function() {
// Web Socket is connected. You can send data by send() method.
ws.send("message to send"); ....
};
ws.onmessage = function (evt) { var received_msg = evt.data; ... };
ws.onclose = function() { // websocket is closed. };
} else {
// the browser doesn't support WebSocket.
}
In addition to the new Web Sockets API, there is also a new protocol (the "web socket protocol") that the browser uses to communicate with servers. We also developed pywebsocket, which can be used as an Apache extension module, or can even be run as standalone server.
----
Personally, there's long way for web sockets to be fully supported by browsers. At this time I would recommend NodeJS or APE Project.
Notifications
Google Chrome has introduced new way to show notifications. They are popping outside browser window and user could see them even if browser is minimalized. Before showing notifications you must ask user for permission to do so. Look at code below and try demo:
if (window.webkitNotifications.checkPermission() == 0) {
// you can pass any url as a parameter
window.webkitNotifications.createNotification(tweet.picture, tweet.title,
tweet.text).show();
} else {
window.webkitNotifications.requestPermission();
}
Drag and Drop
Everyone knows what is it. Thanks to HTML5 we are able to drag and drop any element into any element, without heavy JavaScript frameworks. There's also possibility to drag and drop text/images/files from other windows and desktop.
Geolocation
Probably anything special, but since now we may recognize user's location on frontend as well as backend. Nowadays geolocation is not always accurate and is supported only by Firefox and Safari Mobile.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
map.setCenter(new GLatLng(lat, lng), 13);
map.addOverlay(new GMarker(new GLatLng(lat, lng)));
});
}
Audio and Video manipulation
We can easily embed audio or video on page and super-duper-easily manipulate them with JavaScript.
<audio src="sound.mp3" controls></audio>
document.getElementById("audio").muted=false;
<video src='movie.mp4' autoplay controls></video>
document.getElementById("video").play();
For non-modern browsers you may include html5media. You may also be intrested in HTML5 video player.
Go to audio demo
Go to video demo
Canvas
The best of all! We are able to actually draw in browser. Even second Mac OS if we have patience. Canvas is supported by any browser (even IE thanks to ExplorerCanvas). There's huge set of canvas demos at ChromeExperiments.com. There's CAKE (scenegraph library for the canvas tag). We could write games, physics engines, editors and even whole UI. Flash CS5 will export to HTML5 Canvas and even now we are able to run swf files using pure JavaScript and <canvas> tag (yes, now we can run flash on iPhone).
Useful links
- Check browser support for HTML5 features and view some demos
- Current HTML specification
- HTML5 Presentation
- Detect support for HTML5 features with Modernizr
- Sent (0)
- Nouveau
Générez vos vidéos d'entreprise par l'IA avec la voix ou simplement du texte
chatGPTaz.com
Parlez à ChatGPT dans votre langue maternelle
AppAIVidéo
Votre première application vidéo AI GRATUITE
Deepfake Video
Deepfake AI Video Maker
Deepfake
Deepfake AI Video Maker
AI Deep Fake
Deepfake AI Video Maker
AIvidio
AI Video Mobile Solutions
AIvideos
AI Video Platform & Solutions
AIvedio
AI Video App Maker
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Temu gratuit 500 $ pour les nouveaux utilisateurs
Claim Free Temu $500 Credit via Affiliate & Influencer Program
Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise
Dall-E-OpenAI.com
Générez automatiquement des images créatives avec l'IA
chatGPT4.win
Parlez à ChatGPT dans votre langue maternelle
Premier produit d'intelligence artificielle d'Elon Musk - Grok/UN.com
Parlez au chatbot Grok AI dans votre langue
Outily.win
Centre d'outils ouvert et gratuit, utilisable par tous et pour tous, avec des centaines d'outils
GateIO.gomymobi.com
Airdrops gratuits à réclamer et à partager jusqu'à 150 000 $ par projet
iPhoneKer.com
Économisez jusqu'à 630 $ à l'achat d'un nouvel iPhone 16
Acheter le robot Tesla Optimus
Commandez votre robot Tesla Bot : Optimus Gen 2 dès aujourd'hui pour moins de 20 000 $