mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
sample/ws-chat.html: allow to open it via file:// protocol
This commit is contained in:
parent
2dfad6c339
commit
dda05f45e7
@ -29,7 +29,11 @@ window.onload = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (window["WebSocket"]) {
|
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) {
|
conn.onclose = function (evt) {
|
||||||
var item = document.createElement("div");
|
var item = document.createElement("div");
|
||||||
item.innerHTML = "<b>Connection closed.</b>";
|
item.innerHTML = "<b>Connection closed.</b>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user