Javascript Reference
Categories: Dialog Helper

javascript Dialog Helper ChooseColorDlg( )

@March 15, 2008, 1:22 a.m.
ChooseColorDlg( )Firefox/Netscape/NN n/a IE 6 Chrome/Safari/DOM n/a  



Displays a color selector dialog box, and returns a decimal number corresponding to the color chosen by the user. To apply the color to style or other color property settings, you may have to convert the decimal value to a suitable hexadecimal triplet value of the #RRGGBB format. The following fragment demonstrates the sequence of obtaining the color, converting it to the desired base and digit count, and assigning the value to a style property:

var colorChoice = dlgHelper.ChooseColorDlg( );
var hexColor = colorChoice.toString(16);
while (hexColor.length< 6) {hexColor = "0" + hexColor;} = "#" + hexColor; 

If the user selects a custom color in the dialog and adds it to a little shortcut box, the color does not reappear in the box the next time the dialog appears. But a custom color can still be pre-selected by passing its hex value as a parameter to the method.


Optional hexadecimal number that presets the initially-selected color in the dialog box.

Returned Value

Decimal integer of the selected color (0 through as many colors of the client settings).

Powered by Linode.