IE11 WebSocket object onopen: object expected











up vote
0
down vote

favorite












I'm working in a chatsystem using websockets. Soon I realised it didn't work well in IE11 and Edge. So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016. Unfortunetely IE11 keeps bugging me like crazy!



I'm getting an Object Expected error on Socket.onopen in the following code:



function Chat(){
/* Settings */
this.serverHost = window.location.host;
this.serverPort = 9300;
this.socket = false;
}

Chat.prototype.connect = function(){
var Socket = new WebSocket('wss://'+this.serverHost+'/myws/');
this.setSocketEvents(Socket);
this.socket = Socket;
}

Chat.prototype.setSocketEvents = function(Socket){
Socket.onopen(function() { // Object expected error
// some code..
});
}


Console log: Socket



{binaryType: "blob", bufferedAmount: 0, CLOSED: 3, CLOSING: 2, CONNECTING: 0, extensions: "", onclose: null, onerror: null, onmessage: null, onopen: null, OPEN: 1, protocol: "", readyState: 0, url: "wss://mywebsite..."}


Console log: typeof(Socket)



object


I'm pretty much lost here. Anyone able to tell me what's going on?










share|improve this question


















  • 1




    "So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
    – James Thorpe
    Nov 7 at 13:46










  • Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
    – icecub
    Nov 7 at 13:46










  • @JamesThorpe Thank you very much! That actually saved me a lot of trouble!
    – icecub
    Nov 7 at 14:15















up vote
0
down vote

favorite












I'm working in a chatsystem using websockets. Soon I realised it didn't work well in IE11 and Edge. So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016. Unfortunetely IE11 keeps bugging me like crazy!



I'm getting an Object Expected error on Socket.onopen in the following code:



function Chat(){
/* Settings */
this.serverHost = window.location.host;
this.serverPort = 9300;
this.socket = false;
}

Chat.prototype.connect = function(){
var Socket = new WebSocket('wss://'+this.serverHost+'/myws/');
this.setSocketEvents(Socket);
this.socket = Socket;
}

Chat.prototype.setSocketEvents = function(Socket){
Socket.onopen(function() { // Object expected error
// some code..
});
}


Console log: Socket



{binaryType: "blob", bufferedAmount: 0, CLOSED: 3, CLOSING: 2, CONNECTING: 0, extensions: "", onclose: null, onerror: null, onmessage: null, onopen: null, OPEN: 1, protocol: "", readyState: 0, url: "wss://mywebsite..."}


Console log: typeof(Socket)



object


I'm pretty much lost here. Anyone able to tell me what's going on?










share|improve this question


















  • 1




    "So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
    – James Thorpe
    Nov 7 at 13:46










  • Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
    – icecub
    Nov 7 at 13:46










  • @JamesThorpe Thank you very much! That actually saved me a lot of trouble!
    – icecub
    Nov 7 at 14:15













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm working in a chatsystem using websockets. Soon I realised it didn't work well in IE11 and Edge. So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016. Unfortunetely IE11 keeps bugging me like crazy!



I'm getting an Object Expected error on Socket.onopen in the following code:



function Chat(){
/* Settings */
this.serverHost = window.location.host;
this.serverPort = 9300;
this.socket = false;
}

Chat.prototype.connect = function(){
var Socket = new WebSocket('wss://'+this.serverHost+'/myws/');
this.setSocketEvents(Socket);
this.socket = Socket;
}

Chat.prototype.setSocketEvents = function(Socket){
Socket.onopen(function() { // Object expected error
// some code..
});
}


Console log: Socket



{binaryType: "blob", bufferedAmount: 0, CLOSED: 3, CLOSING: 2, CONNECTING: 0, extensions: "", onclose: null, onerror: null, onmessage: null, onopen: null, OPEN: 1, protocol: "", readyState: 0, url: "wss://mywebsite..."}


Console log: typeof(Socket)



object


I'm pretty much lost here. Anyone able to tell me what's going on?










share|improve this question













I'm working in a chatsystem using websockets. Soon I realised it didn't work well in IE11 and Edge. So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016. Unfortunetely IE11 keeps bugging me like crazy!



I'm getting an Object Expected error on Socket.onopen in the following code:



function Chat(){
/* Settings */
this.serverHost = window.location.host;
this.serverPort = 9300;
this.socket = false;
}

Chat.prototype.connect = function(){
var Socket = new WebSocket('wss://'+this.serverHost+'/myws/');
this.setSocketEvents(Socket);
this.socket = Socket;
}

Chat.prototype.setSocketEvents = function(Socket){
Socket.onopen(function() { // Object expected error
// some code..
});
}


Console log: Socket



{binaryType: "blob", bufferedAmount: 0, CLOSED: 3, CLOSING: 2, CONNECTING: 0, extensions: "", onclose: null, onerror: null, onmessage: null, onopen: null, OPEN: 1, protocol: "", readyState: 0, url: "wss://mywebsite..."}


Console log: typeof(Socket)



object


I'm pretty much lost here. Anyone able to tell me what's going on?







javascript jquery internet-explorer-11






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 13:44









icecub

5,22632246




5,22632246








  • 1




    "So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
    – James Thorpe
    Nov 7 at 13:46










  • Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
    – icecub
    Nov 7 at 13:46










  • @JamesThorpe Thank you very much! That actually saved me a lot of trouble!
    – icecub
    Nov 7 at 14:15














  • 1




    "So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
    – James Thorpe
    Nov 7 at 13:46










  • Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
    – icecub
    Nov 7 at 13:46










  • @JamesThorpe Thank you very much! That actually saved me a lot of trouble!
    – icecub
    Nov 7 at 14:15








1




1




"So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
– James Thorpe
Nov 7 at 13:46




"So I've started working on a seperate JS file for those browsers using ES2015 instead of ES2016" - you can always transpile your ES2016 code to a lower version for older browsers
– James Thorpe
Nov 7 at 13:46












Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
– icecub
Nov 7 at 13:46




Wait.. I think I just realised IE11 probably needs Socket.onopen = function(){ instead..
– icecub
Nov 7 at 13:46












@JamesThorpe Thank you very much! That actually saved me a lot of trouble!
– icecub
Nov 7 at 14:15




@JamesThorpe Thank you very much! That actually saved me a lot of trouble!
– icecub
Nov 7 at 14:15

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190690%2fie11-websocket-object-onopen-object-expected%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190690%2fie11-websocket-object-onopen-object-expected%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini