Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

<html> <head>

  <script type="text/javascript">

    // make global reference
    var serial;

    function setup()
    {
      // instantiate seriality
      serial = (document.getElementById("seriality")).Seriality();

      // begin serial communications on first known port at 9600 baud
      serial.begin(serial.ports[0], 9600);

      // write a '-' to set the initial state of the LED to off
      serial.write('-');

      // note the use of 'onload' and 'onclick' below...
    }

  </script>

</head> <body onload="setup()">

  <object type="application/Seriality" id="seriality" width="0" height="0"> </object>

  <form>
    ON <input type="radio" name="led" value="on" onclick="serial.write('!');"><br/>
    OFF <input type="radio" name="led" value="off" onclick="serial.write('-');" checked="checked">
  </form>

</body> </html>