1 Star 0 Fork 0

Gavin / html模板

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
JS 216网页安全色调色板.html 4.16 KB
一键复制 编辑 原始数据 按行查看 历史
Gavin 提交于 2020-11-08 13:19 . add file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style>
h1{
color:#00dead;
text-align:center;
}
textarea{
height:600px;
width:500px;
}
</style>
<script>
function runCode(obj) //定义一个运行代码的函数,
{
var code=obj.value;//即要运行的代码。
var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。
newwin.opener = null // 防止代码对论坛页面修改
newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
newwin.document.close();
}
</script>
</head>
<body>
<h1>JS 216网页安全色调色板</h1>
<p>利用JS做的一个网页安全色调色板 希望大家用得上!</p>
<p>运行代码框<br></p>
<div>
<textarea class="codeTextarea">
<!-- start html -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2311">
<title>DW调色板</title>
<script>
var ColorHex=new Array('00','33','66','99','CC','FF')
var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF')
var current=null
function intocolor()
{
var colorTable=''
for (i=0;i<2;i++)
{
for (j=0;j<6;j++)
{
colorTable=colorTable+'<tr height=12>'
colorTable=colorTable+'<td width=11 style="background-color:#000000">'
if (i==0){
colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[j]+ColorHex[j]+ColorHex[j]+'">'}
else{
colorTable=colorTable+'<td width=11 style="background-color:#'+SpColorHex[j]+'">'}
colorTable=colorTable+'<td width=11 style="background-color:#000000">'
for (k=0;k<3;k++)
{
for (l=0;l<6;l++)
{
colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'">'
}
}
}
}
colorTable='<table width=253 border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse" bordercolor="000000">'
+'<tr height=30><td colspan=21 bgcolor=#cccccc>'
+'<table cellpadding="0" cellspacing="1" border="0" style="border-collapse: collapse">'
+'<tr><td width="3"><td><input type="text" name="DisColor" size="6" disabled style="border:solid 1px #000000;background-color:#ffff00"></td>'
+'<td width="3"><td><input type="text" name="HexColor" size="7" style="border:inset 1px;font-family:Arial;" value="#000000"></td></tr></table></td></table>'
+'<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" onmouseover="doOver()" onmouseout="doOut()" onclick="doclick()" style="cursor:hand;">'
+colorTable+'</table>';
colorpanel.innerHTML=colorTable
}
function doOver() {
if ((event.srcElement.tagName=="TD") && (current!=event.srcElement)) {
if (current!=null){current.style.backgroundColor = current._background}
event.srcElement._background = event.srcElement.style.backgroundColor
DisColor.style.backgroundColor = event.srcElement.style.backgroundColor
HexColor.value = event.srcElement.style.backgroundColor
event.srcElement.style.backgroundColor = "white"
current = event.srcElement
}
}
function doOut() {
if (current!=null) current.style.backgroundColor = current._background
}
function doclick(){
if (event.srcElement.tagName=="TD"){
alert("选取颜色: "+event.srcElement._background)
return event.srcElement._background
}
}
</script>
</head>
<body onload="intocolor()">
<div id="colorpanel" style="position: absolute;">
 </div>
</body>
</html>
<!-- end html -->
</textarea>
<br>
<input type="button" value="运行代码" onclick="runCode(document.getElementsByTagName('textarea')[0])">
</body>
</html>
1
https://gitee.com/gavin-chan/html-template.git
git@gitee.com:gavin-chan/html-template.git
gavin-chan
html-template
html模板
master

搜索帮助