What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-14 20:44:03
js connect to websocket
var Socket = new WebSocket('ws://' + window.location.hostname + ':81/'); // The '81' here is the Port where the WebSocket server will communicate with // The instance of the WebSocket() class (i.e. Socket here), must need to be globally defined Socket.se... Add solution -
Javascript 2021-09-30 08:50:02
js host without port
// host without the port window.location.hostname Add solution -
Javascript 2021-09-15 13:58:05
javascript websocket
var Socket = new WebSocket('ws://' + window.location.hostname + ':81/'); // The '81' here is the Port where the WebSocket server will communicate with // The instance of the WebSocket() class (i.e. Socket here), must need to be globally defined Socket.se... Add solution -
Javascript 2021-08-30 17:36:01
get the domain name in javascript
window.location.hostname Add solution