JavaScript实现获取颜色选择器功能(图)
代码
<script>
function $(obj)
{
return document.getElementById(obj);
}
function pickColor()
{
if (!window.isIE) return;
var sColor = $('dlgHelper').ChooseColorDlg();
var color = sColor.toString(16);
while (color.length<6) color="0"+color;
window.color = color;
color = "#"+color;
$('div_color').style.backgroundColor = color;
$('div_color').value = color;
}
var isIE = (document.all && window.ActiveXObject) ? true : false;
</script>
<OBJECT id="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT>
<input class="inputtext" style='width:50px;cursor:hand;10px;background-color:#000000;color:#ffffff;' id='div_color' value="#000000" />
<input type="button" value='获取颜色'>
function $(obj)
{
return document.getElementById(obj);
}
function pickColor()
{
if (!window.isIE) return;
var sColor = $('dlgHelper').ChooseColorDlg();
var color = sColor.toString(16);
while (color.length<6) color="0"+color;
window.color = color;
color = "#"+color;
$('div_color').style.backgroundColor = color;
$('div_color').value = color;
}
var isIE = (document.all && window.ActiveXObject) ? true : false;
</script>
<OBJECT id="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT>
<input class="inputtext" style='width:50px;cursor:hand;10px;background-color:#000000;color:#ffffff;' id='div_color' value="#000000" />
<input type="button" value='获取颜色'>
具体效果,大家可以自己测试,或者移步安徽PHP社区 http://bbs.hfphp.org
或者jincon‘s 包 Blog http://www.yi1.com.cn
来源:http://bbs.hfphp.org/thread-1372-1-1.html