'WebSocket SyntaxError: An invalid or illegal string was specified

I'm getting a SyntaxError: An invalid or illegal string was specified, while trying to connect to a WebSocket on Firefox.

<!doctype html>
<html>
  <head><meta charset="utf-8"></head>
  <body>
    <script>
    var socket = new WebSocket('127.0.0.1:1234');
    </script>
  </body>
</html>

Why do I get this error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source