mirror of
				https://github.com/KevinMidboe/delugeClient.git
				synced 2025-10-29 12:00:13 +00:00 
			
		
		
		
	Updated with text input field.
This commit is contained in:
		
							
								
								
									
										10
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.html
									
									
									
									
									
								
							| @@ -4,13 +4,18 @@ | ||||
|         <title>WebSocket demo</title> | ||||
|     </head> | ||||
|     <body> | ||||
|         <input placeholder="Your name here"></input> | ||||
|         <button onclick="sendMessage()">Send message</button> | ||||
|         <br /> | ||||
|         <span>Message from server: </span> | ||||
|         <span id="response"></span> | ||||
|  | ||||
|         <script> | ||||
|         function sendMessage() { | ||||
|             let ws = new WebSocket("ws://localhost:8765/") | ||||
|             let test = 'hello' | ||||
|             ws.onopen = function (event) { | ||||
|                 ws.send("Kevin"); | ||||
|                 ws.send(document.getElementsByTagName('input')[0].value); | ||||
|             } | ||||
|             ws.onerror = function() { | ||||
|                 console.error("error"); | ||||
| @@ -20,7 +25,8 @@ | ||||
|             } | ||||
|             ws.onmessage = function (event) { | ||||
|                 let server_resp = event.data; | ||||
|                 document.getElementsByTagName('span')[0].innerHTML += server_resp; | ||||
|                 document.getElementById('response').textContent= server_resp; | ||||
|             }    | ||||
|         } | ||||
|         </script> | ||||
|         <script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user