1、修改https下websocket建立失败的问题

This commit is contained in:
weidong 2024-01-02 19:48:45 +08:00
parent 0bd5a0e507
commit 006a23f6ed

View File

@ -117,8 +117,10 @@
function connectWebSocket() { function connectWebSocket() {
//获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
var curPath = window.document.location.href; var curPath = window.document.location.href;
console.log(curPath);
//获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
var pathName = window.document.location.pathname; var pathName = window.document.location.pathname;
console.log(curPath);
var pos = curPath.indexOf(pathName); var pos = curPath.indexOf(pathName);
//获取主机地址,如: http://localhost:8080 //获取主机地址,如: http://localhost:8080
var basePath = curPath.substring(0, pos); var basePath = curPath.substring(0, pos);
@ -134,7 +136,7 @@
} }
websocket.onerror = function (){ websocket.onerror = function (){
console.log("Socket error"); console.log("Socket error");
layui.alert("Open web socket failed!"); layui.layer.alert("Open web socket failed!");
} }
//接收信息 //接收信息
websocket.onmessage = function (event) { websocket.onmessage = function (event) {