Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <div id="log">Hello World</div>
  <script type="text/javascript">
    window.onerror = function() {
      console.log('window.onerror')
    }
      
      function log( msg ) {
        var el = document.createElement( 'p' );
        var text = document.createTextNode( msg );
        el.appendChild( text );
        document.getElementById( 'log' ).appendChild( el );
      }
    var Socket = window['MozWebSocket'] || window['WebSocket']
    if (Socket) {
      try {
        var ws = new Socket('ws://localhost:8080/')
        ws.onopen = function() { console.log('onopen'); };
        ws.onerror = function() { console.log('onerror attached to websocket object.'); };
        ws.onclose = function() { console.log('onclose'); };
        ws.onmessage = function(evt) { console.log('onmessage: '+evt.data); };
        // Close as soon as open is called.
        try { 
          ws.close();
        } catch (e) {
          log('try/catch around ws.close()')
        }
      } catch (e) {
        log('try/catch around entire ws code.')
      }
    }
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
leggetterpro
0viewers