⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8-4-color_dialog.htm

📁 JAVASCRIPT完全自学手册,中源码的验证修订实例
💻 HTM
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>请选择色彩</title>
<!-- 样式表 -->
<style>
* { font-size:12px; font-family:宋体, Arial; font-weight:normal; color:#333; } /*规定了所有的字体样式*/
.divColor { width:10px; height:10px; overflow:hidden; }
#divContainer { border-collapse:collapse; cursor:pointer; }
</style>
<!-- 脚本部分 -->
<script>
function writeColorDiv(iRed, iGreen, iBlue){
    var strColor, index;
    strColor = "#" + iRed.toString(16) + iRed.toString(16);
    strColor += iGreen.toString(16) + iGreen.toString(16);
    strColor += iBlue.toString(16) + iBlue.toString(16);
    document.write("<td><div class=\"divColor\" style=\"background-color:" + strColor + ";");
    document.write("\"></div></td>");
    index = iRed*64 + iGreen*4 + iBlue/2;
    if(index%32==31)document.write("</tr><tr>");
}

function mover(){
    $("txtColor").value = event.srcElement.style.backgroundColor;
}

function returnColor(){
    if(!window.opener)return;
    window.opener.setColor($("txtColor").value);
    window.close();
}
function $(str){ return(document.getElementById(str)); }
</script>
</head>
<body style="overflow:auto;">
    请单击选择需要的色彩值:<input id="txtColor">
    <table id="divContainer" border=0 cellpadding=0 cellspacing=0 onmouseover="mover();" onclick="returnColor();" >
        <tr>
        <script>
            for(var i=0; i<16; i+=1)for(var j=0; j<16; j+=2)for(var k=0; k<16; k+=2){
                writeColorDiv(i, j, k);
            }
        </script>
        </tr>
    </table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -