Get the App
SLTechnology News&Howtos  ›  Development  › 

How does JavaScript handle messages in web pages

Shulou Source: shulou.com Published: 2022-06-01 03:52:18 09月15日 Update

This article mainly explains "how JavaScript handles messages in web pages". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how JavaScript handles messages in web pages"!

This EventSource object is used to receive event messages sent by the server.

Now we create an HTML document called " demo_sse.html" and place it in the project directory where the " server_time.php" file is located. This HTML document simply receives the current time reported by the Web server and displays it to the user.

The code is as follows:

Using Server-Sent Events

_window.onload = function() {

var source = new EventSource("server_time.php");

source.onmessage = function(event) {

document.getElementById("result")[xss_clean] += "New time received from web server: " + event.data + "

";

};

};

At this point, I believe that everyone has a deeper understanding of "how JavaScript handles messages in web pages", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Message web page processing content document server and will learning service practical deeper event code interest practicality actual object location report simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn macOS MySQL Docker