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?
javascript jquery internet-explorer-11
add a comment |
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?
javascript jquery internet-explorer-11
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 needsSocket.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
add a comment |
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?
javascript jquery internet-explorer-11
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
javascript jquery internet-explorer-11
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 needsSocket.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
add a comment |
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 needsSocket.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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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