最简单的,在body区域加入:
<OBJECT id="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0" height="0"></OBJECT>
调用的JS:
<script type="text/javascript">
var tempColor = "0099cc";
function picColor(){
var Hcolor = document.getElementById("dlgHelper").ChooseColorDlg(tempColor).toString(16);
//with(event.srcElement){
//value = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;
//style.backgroundColor = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;
var newColor = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;
if(newColor.toString().substring(0,1) != "#"){
newColor = "#" + newColor;
}
alert(newColor);
}
// tempColor = Hcolor;
// window.alert(tempColor);
//}
</script>
或者直接使用这个: