
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How can I handle Server-Sent Events in HTML5?
To handle Server-Sent Events in HTML5, you can try to run the following code:
<!DOCTYPE HTML> <html> <head> <script> document.getElementsByTagName("eventsource")[0].addEventListener("server-time", eventHandler, false); function eventHandler(event) { // Alert time sent by the server document.querySelector('#ticker').innerHTML = event.data; } </script> </head> <body> <div id = "sse"> <eventsource src = "/cgi-bin/ticker.cgi" /> </div> <div id = "ticker" name = "ticker"> [TIME] </div> </body> </html>
- Related Articles
- How Server-Sent Events Works in HTML5?
- HTML5 Server-Sent Events working
- Using HTML5 Server-Sent Events in a web application
- Is there a Microsoft equivalent for HTML5 Server-Sent Events?
- What is server-sent events in JavaScript?
- What are the events available for server sent events in JavaScript?
- How to handle HTML5 media events using jQuery?
- What are Long-Polling, Websockets, Server- Sent Events (SSE) and Comet?
- How to Handle JavaScript Events in HTML?
- How do you receive server-sent event notifications in JavaScript?
- How can I start MySQL Server?
- How can I shutdown MySQL Server?
- How to handle Geolocation errors in HTML5?
- How can I use Web Workers in HTML5?
- How to handle errors in HTML5 Web Workers?

Advertisements