title: Node.js Server - how to pass buttonclick function from client to client
body: <p>What I'm trying to do is something like little chat taht I already made with some help. But what I want rly is taht when clicing on button1 (oppens new page) client1 passes buttonclick to client2 and same action happens on client2 (opens new page), something like remote control.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var nowjs = require('now');
  var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  app.get('/', function(req, res){
      res.sendFile(__dirname + '/startHTM.htm');
  });
  
  io.on('connection', function(socket){
      socket.on('chat message', function(msg){
          io.emit('chat message', msg);
      });
  });
  
  http.listen(8080, function(){
      console.log('listening on *:8080');
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Socket.IO chat&lt;/title&gt;
          &lt;style&gt;
              * { margin: 0; padding: 0; box-sizing: border-box; }
              body { font: 13px Helvetica, Arial; }
              form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
              form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
              form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
              #messages { list-style-type: none; margin: 0; padding: 0; }
              #messages li { padding: 5px 10px; }
              #messages li:nth-child(odd) { background: #eee; }
          &lt;/style&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;ul id="messages"&gt;&lt;/ul&gt;
          &lt;form action=""&gt;
              &lt;input id="m" autocomplete="off" /&gt;&lt;button&gt;Send&lt;/button&gt;
          &lt;/form&gt;
          &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/jquery-1.11.1.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      var socket = io();
      $('form').submit(function(){
          socket.emit('chat message', $('#m').val());
          $('#m').val('');
          return false;
      });
      socket.on('chat message', function(msg){
          $('#messages').append($('&lt;li&gt;').text(msg));
      });
  &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thx for further help!</p>