Skip to content

Commit

Permalink
sample/ws-chat.html: allow to open it via file:// protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
azat committed Nov 12, 2022
1 parent 2dfad6c commit dda05f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sample/ws-chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<b>Connection closed.</b>";
Expand Down

0 comments on commit dda05f4

Please sign in to comment.