Search code examples
javascriptjqueryhtmlnode.jsnode-webkit

Nodejs send commands to http server to highlight or color the DOM element


I created server which listens to data from gaze sensor and a http server which loads a html page. I want to highlight the elements in html depending on data received. Any pointers to what I should be searching or reading to accomplish that task. Thanks

I came across the following link http://marksoper.me/Server-side-DOM-manipulation-in-Nodejs-with-JSDOM-JQuery-and-Mustache-Templates-April-25-2011.html , My intention is not rendering data, but to in highlight or color the already loaded data.


Solution

  • You can do that by using websockets.

    In Node.js there's a great lib for websockets called socket.io http://socket.io/ You can find examples by googling, it's very easy to use.

    Basically your client (browser with your HTML page loaded) connects to the server via websocket. It creates a connection between server and client that it's always listen to events in both ways. Server can emmit messages to client and vice versa. Analogously server can listen to messages from the client and vice versa.

    Using this technology you can listen to messages from server and make your DOM manipulations in the client in real time.