Share via


colorpick Behavior

This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.

Adds a color picker that can be used to select a specific color from a preset palette.

Syntax

XML
  		N/A
  	</td>
HTML <INPUT type=text STYLE="behavior:url('colorpick.htc')" ID=sID>
Scripting object.style.behavior = "url('colorpick.htc')"
object.addBehavior ("colorpick.htc")

Possible Values

sID String that specifies a unique identifier for the object.

Members Table

The following table lists the members exposed by the colorpick object.

Attribute Property Description
cp--cell-height cpCellHeight Sets or retrieves the height of individual colors displayed by the colorpick behavior.
cp--cell-width cpCellWidth Sets or retrieves the width of individual colors displayed by the colorpick behavior.
cp--grid-height cpGridHeight Sets or retrieves the height of the colorpick behavior.
cp--grid-size cpGridSize Sets or retrieves the number of colors that are displayed by the colorpick behavior.
cp--grid-style cpGridStyle Sets or retrieves the borderWidth, borderStyle, and borderColor properties to be drawn around the individual colors of the colorpick behavior.
cp--grid-width cpGridWidth Sets or retrieves the width of the colorpick behavior.
cp--hover-style cpHoverStyle Sets or retrieves the borderWidth, borderStyle, and borderColor properties to be drawn when the mouse cursor hovers over a particular color.
cp--selected-style cpSelectedStyle Sets or retrieves the borderWidth, borderStyle, and borderColor properties to be drawn around a selected color in the colorpick behavior.
NAME name Sets or retrieves the name of the colorpick behavior.
VALUE value Sets or retrieves the value of the colorpick behavior.
Event Property Description
onchange Fires when the color is changed for the colorpick behavior.
onerror Fires when a property is assigned an invalid value, or the property is read-only, for the colorpick behavior.

Remarks

The behavior-defined members listed in the preceding table are not accessible through script until the window. onload event fires. Waiting for this event to fire ensures that the document is completely loaded, that all behaviors have been applied to corresponding elements on the document , and, consequently, that all the behavior's properties, methods, and events are available for scripting. Attempting to use any of the behavior-defined members will result in a scripting error indicating that the object does not support that particular member.

The colorpick.htc file can be downloaded from the colorpick  sample page.

Example

This sample demonstrates the implementation of the colorpick behavior to add an 8-color palette to a document.

<SCRIPT>
function fnColorChange(){
    oTitle.style.color=cp.value;
}
</SCRIPT>
<STYLE>
   .colorpick{behavior: url(ColorPick.htc)}
   H1 {font: bold 18pt verdana; color: navy;}
   P {font: 10pt verdana;}
</STYLE>
<h1 ID="oTitle">Color Picker</h1>
<INPUT ID="oColor"
   TYPE="text"
   CLASS="colorpick" 
   STYLE="cp--grid-size:2"   
   onchange="fnColorChange()">

Code example: https://samples.msdn.microsoft.com/workshop/samples/author/behaviors/library/colorpick/colorpick.htm

Applies To

INPUT type=text

See Also

Introduction to DHTML Behaviors, Using DHTML Behaviors