summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2022-11-12 18:11:08 +0100
committerAzat Khuzhin <azat@libevent.org>2022-11-12 18:11:08 +0100
commitdda05f45e7642275c41884c59b5cd562c9f28796 (patch)
tree157ce4eb8117f44e7964573a882bfd96e34064f0 /sample
parent2dfad6c339a68c42e98049e7e3d60db6d500a1ac (diff)
downloadlibevent-dda05f45e7642275c41884c59b5cd562c9f28796.tar.gz
sample/ws-chat.html: allow to open it via file:// protocol
Diffstat (limited to 'sample')
-rw-r--r--sample/ws-chat.html6
1 files changed, 5 insertions, 1 deletions
diff --git a/sample/ws-chat.html b/sample/ws-chat.html
index f4083f80..1a39efa4 100644
--- a/sample/ws-chat.html
+++ b/sample/ws-chat.html
@@ -29,7 +29,11 @@ window.onload = function () {
};
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 = "<b>Connection closed.</b>";