There is know bug where Firefox closes the open websocket connection when the user presses ESC button. Is there a workaround or small jQuery code that can help me to prevent that? I was thinking to start a new websocket connection every time the current connection is being closed, but that seems a little dangerous.
Have a look at https://bugzilla.mozilla.org/show_bug.cgi?id=676881 where this problem and a partial fix is discussed. The following snippet executed after the page is loaded works for me:
$(window).keydown(function(event) {
// check for escape key
if (event.which == 27) {
// the following seems to fix the symptom but only in case the document has the focus
event.preventDefault();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With