<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT><!--系统颜色盘的全局ID-->
 
<script>
var tempColor = "0099cc";
function returnColor(){
 var Hcolor = dlgHelper.ChooseColorDlg(tempColor).toString(16);//以16进制获取通过系统颜色盘选择的颜色
 with(event.srcElement){//获取当前事件对象,也就是文本框
 value = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor; //组合成6位的字符串
 style.backgroundColor = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor; 
 } //设置背景色
 tempColor = Hcolor
}
</script>
<input type="text" value="#0099CC" size="12" onclick="returnColor()" style="background-color: #0099CC">

解决方案 »

  1.   

    怎么把这个windows的颜色选择器掉出来的呀
    <OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
    这个有什么用啊
    反正很多都不懂了
    嘿嘿 
    没这方面的基础   不知道从什么地方开始看起
      

  2.   

    就是调用window自带的颜色选择器
    dlgHelper.ChooseColorDlg(tempColor) 打开选择器 默认选择颜色为tempColor 得到颜色是一个Long 
      

  3.   

    你去你的注册表中找下 3050f819-98b5-11cf-bb82-00aa00bdce0b 就知道是啥了
    <OBJECT>是通过classid调用你本地已安装的组件
      

  4.   

    稍微改动了一下,加简单注释
    <OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT><!--创建选择器对象-->
    <script>
    var tempColor ="";
    function returnColor(){
      var Hcolor = dlgHelper.ChooseColorDlg(tempColor).toString(16);//将选择的颜色值转换为16进制
      with(event.srcElement){//定义源控件(这里就是下面的TEXT)相关属性
        //如果取得的16进制小于6位,用0补足6位
        tempColor =Hcolor.length<6?"000000".substring(0,6-Hcolor.length):"" 
        value =tempColor +Hcolor;
        style.backgroundColor =tempColor +Hcolor;
      }
      tempColor = Hcolor;
    }
    </script>
    <input type="text" value="#0099CC" size="7" onclick="returnColor()" style="background-color: #0099CC;cursor:pointer;">