我正在尝试从trial.domain.com连接到server.domain.com上的websocket。
在Firefox中出现NS_ERROR_DOM_SECURITY_ERR错误:
"[Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "https://trial.domain.com/home Line: 454"]"
当我尝试建立WebSocket连接时:
try {
if (window['MozWebSocket'] !== undefined) {
socket = new MozWebSocket('ws://server.domain.com/chat');
} else {
socket = new WebSocket('ws://server.domain.com/chat');
}
trails = 0;
} catch(err){
trials++;
}
MozWebSocket
,而应该寻找WebSocket
构造函数,仅当找不到时才尝试使用MozWebSocket
构造函数。 - Neil