You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Color Picker

Feature Owner
Stuart Parmenter

A color picker is a frame that contains a graphical representation of multiple colors.

The color picker is specified using the colorpicker tag. The attribute type is used to specify the type of color picker such as swatch. If this attribute is omitted, the color picker will be a swatch. The only color picker currently implemented is a swatch.

<colorpicker type="swatch"/>

Palettes can be chosen using the palettename attribute. Currently supported are standard which is a 70 color palette, web which is the 216 "web safe" palette, and grey which is a grey scale palette. If this attribute is omitted, you will get the standard palette. It is currently not possible to change colors or add custom colors.

<colorpicker type="swatch" palettename="web"/>

When a color is selected, the color attribute is set containing the color that was selected. An example of this is below:

<html:script type="application/x-javascript">
  function doSomethingUseful(cp)
  {
    var color = cp.getAttribute('color');
    document.getElementById("input").value = color;
  }
</html:script>

<colorpicker id="cp" onclick="doSomethingUseful(this);"/>
<html:input id="input"/>