[Solved] How to execute javascript functions in client-side in browsers with Node-JS? [closed]


You can’t, per se.

You have two different programs running on two different computers. The fact they are written in the same programming language is beside the point.

The closest you can get is to write some client-side JavaScript that will show the alert when it receives a message over the network, and some server-side JavaScript which will send that message at the appropriate time.

Standard HTTP works is a stateless client-server protocol so using that you would have to poll (e.g. using the fetch API) the server to so it can respond with the message at the appropriate time.

A more efficient, but complex, approach would be to use WebSockets instead of HTTP so that the server and trigger the message.

1

solved How to execute javascript functions in client-side in browsers with Node-JS? [closed]