From dda05f45e7642275c41884c59b5cd562c9f28796 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 12 Nov 2022 18:11:08 +0100 Subject: [PATCH] sample/ws-chat.html: allow to open it via file:// protocol --- sample/ws-chat.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sample/ws-chat.html b/sample/ws-chat.html index f4083f8046..1a39efa483 100644 --- a/sample/ws-chat.html +++ b/sample/ws-chat.html @@ -29,7 +29,11 @@ }; if (window["WebSocket"]) { - conn = new WebSocket("ws://" + document.location.host + ":8080/ws"); + var host = document.location.host; + if (!host) { /// file:/// + host = "localhost"; + } + conn = new WebSocket("ws://" + host + ":8080/ws"); conn.onclose = function (evt) { var item = document.createElement("div"); item.innerHTML = "Connection closed.";