File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 44 </ head >
55 < body >
66 < h1 > Server Time</ h1 >
7- < strong id ="time "> </ strong >
8-
9- < script >
10- var socket = new WebSocket ( "ws://localhost:12345/ " ) ;
11- socket . onmessage = function ( msg ) {
12- document . getElementById ( "time " ) . innerText = msg . data ;
13- } ;
14- </ script >
7+ < div > Status: < span id ="status "> </ span > </ div >
8+ < div > Time: < span style =" font-size:bold; " id =" time " > </ span > </ div >
9+ < script type =" text/javascript " >
10+ var socket = new WebSocket ( "ws://localhost:12345" ) ;
11+ socket . onopen = function ( msg ) { document . getElementById ( "status" ) . innerHTML = 'Online' ; } ;
12+ socket . onclose = function ( msg ) { document . getElementById ( "status " ) . innerHTML = 'Offline' ; }
13+ socket . onmessage = function ( msg ) { document . getElementById ( "time" ) . innerHTML = msg . data ; } ;
14+ </ script >
1515 </ body >
16- </ html >
16+ </ html >
You can’t perform that action at this time.
0 commit comments