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 = "Connection closed.";