在set_color.html里面。有下面的函数。function return_color()
{
window.returnValue = SelColor.value;
window.close();
}
为何总是返回了undefined?
{
window.returnValue = SelColor.value;
window.close();
}
为何总是返回了undefined?
解决方案 »
- svg 的 rect标签 fill属性 填充图片
- 代码实现backspace键
- javascript截取前面N个字代码怎样写?
- 自己写的javascrip函数里可以调用.java文件并返回参数吗??
- 请问js或vbs能否操作剪贴版?详细问题见内
- 请问showModalDialog()函数show出来的页面能交互吗???
- 如何让radio执行javascript?
- 如何实现鼠标拖动一个层??新春散分,UP也行!!
- 链接®_date在IE地址栏被解析成了®_date,——高手捞分好机会!
- 菜鸟问各位高手一个简单的问题
- 急呀!如何使一个网页的右键、打印、菜单项、copy、cut都不能使用?
- 我想利用javascript实现自动弹出另外一个窗口,然后对第二个窗口进行操作,不知怎样实现?
是什么呀??
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<meta content="MSHTML 5.00.2920.0" name="GENERATOR">
<style type="text/css">
TD{FONT-SIZE: 9pt}
input{font:verdana,arial,sans-serif;FONT-SIZE: 12px;line-height: -3px}
.defcol{font-size:1px;border-left:buttonshadow 2px solid; border-right:buttonhighlight 2px solid; border-top: buttonshadow 2px solid; border-bottom:buttonhighlight 2px solid}
.container{border-left:buttonshadow 1px solid; border-right:buttonhighlight 1px solid; border-top: buttonshadow 1px solid; border-bottom:buttonhighlight 1px solid}
BODY {FONT-SIZE: 10.8pt}
BUTTON { WIDTH: 5em}
</style>
<script language="JavaScript">
<!--
var SelRGB = '#000000';
var DrRGB = '#000000';
var SelGRAY = '120';var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');function ToHex(n)
{
var h, l; n = Math.round(n);
l = n % 16;
h = Math.floor((n / 16)) % 16;
return (hexch[h] + hexch[l]);
}function DoColor(c, cl)
{
var r, g, b,l; r = '0x' + c.substring(1, 3);
g = '0x' + c.substring(3, 5);
b = '0x' + c.substring(5, 7);
l = parseInt(cl);
if(l > 120)
{
l = l - 120; r = (r * (120 - l) + 255 * l) / 120;
g = (g * (120 - l) + 255 * l) / 120;
b = (b * (120 - l) + 255 * l) / 120;
}
else
{
r = (r * l) / 120;
g = (g * l) / 120;
b = (b * l) / 120;
} return '#' + ToHex(r) + ToHex(g) + ToHex(b);
}function EndColor()
{
var i; if(DrRGB != SelRGB)
{
DrRGB = SelRGB;
for(i = 0; i <= 40; i ++)
GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 6);
} SelColor.value = DoColor(RGB.innerText, SelGRAY);
ShowColor.bgColor = SelColor.value;
}function return_color()
{
window.returnValue = SelColor.value;
window.close();
}function sel_color(type)
{
var r,g,b,c;
if(type == "BASE")
{
SelRGB = event.srcElement.style.backgroundColor;
RGB.innerText = SelRGB; r = '0x' + SelRGB.substring(1, 3);
g = '0x' + SelRGB.substring(3, 5);
b = '0x' + SelRGB.substring(5, 7);
colR.value = parseInt(r);
colG.value = parseInt(g);
colB.value = parseInt(b);
SelGRAY = 120;
colL.value = 120;
col.style.pixelTop = GrayTable.rows(20).offsetTop - 2;
for(var i=0;i<30;i++)
if(SelRGB == MainColor.rows(0).cells(i).bgColor)
{
colE.value = i * 8;
colS.value = 240;
EndColor();
return;
}
}
else
{
if(type == "RGB")
{
c = event.srcElement.bgColor;
SelRGB = c;
colE.value = event.srcElement.cellIndex * 8;
colS.value = 240 - 16 * Math.floor((event.srcElement.sourceIndex - event.srcElement.parentElement.parentElement.firstChild.firstChild.sourceIndex)/31);
}
else if(type == "GRAY")
{
c = DoColor(RGB.innerText, SelGRAY);
colL.value = event.srcElement.title;
col.style.pixelTop = event.srcElement.offsetTop - 2;
}
r = '0x' + c.substring(1, 3);
g = '0x' + c.substring(3, 5);
b = '0x' + c.substring(5, 7);
colR.value = parseInt(r);
colG.value = parseInt(g);
colB.value = parseInt(b);
}
EndColor();
}function sel_colorover(type)
{
if(type == "RGB")
RGB.innerText = event.srcElement.bgColor;
else if(type == "GRAY")
SelGRAY = "" + event.srcElement.title;
EndColor();
}function sel_colorout(type)
{
if(type == "RGB")
RGB.innerText = SelRGB;
else if(type == "GRAY")
SelGRAY = colL.value;
EndColor();
}//-->
</script>
</head>
<body bgColor="menu">
<center>
<table border="0" cellPadding="0" cellSpacing="0">
<tr>
<td valign="top" rowspan="2">
<table border="0" cellPadding="0" cellSpacing="4" onclick="sel_color('BASE')">
<tr><td colspan="8">基本颜色:</td></tr>
<script language="javascript">
<!--
var cr = new Array("ff","99","66","00");
var cg = new Array("99","66","ff","00");
var cb = new Array("00","99","ff");
var x=0,y=0,z=0;
var col;
for(var j=0;j<6;j++)
{
document.writeln("<tr>");
for(var i=0;i<8;i++)
{
col = "#" + cr[x] + cg[y] + cb[z];
document.writeln("<td><div class=defcol style=\"BACKGROUND-COLOR:" + col + ";width:20;height:15\"></div></td>");
y ++;
if(y > 3)
{
y = 0;
x ++;
if(x > 3)
{
x = 0;
z ++;
if(z > 2)
z = 0;
}
}
}
document.writeln("</tr>");
}
//-->
</script>
</table>
<br>
<div ALIGN="RIGHT">
<table border="0" cellPadding="0" cellSpacing="2">
<tr>
<td align="right">色调(E):</td>
<td><input type="text" size="3" readonly name="colE" value="160"></td>
<td>红(R):</td>
<td><input type="text" size="3" readonly name="colR" value="0"></td>
</tr>
<tr>
<td align="right">饱和度(S):</td>
<td><input type="text" size="3" readonly name="colS" value="0"></td>
<td>绿(G):</td>
<td><input type="text" size="3" readonly name="colG" value="0"></td>
</tr>
<tr>
<td align="right">亮度(L):</td>
<td><input type="text" size="3" readonly name="colL" value="120"></td>
<td>蓝(B):</td>
<td><input type="text" size="3" readonly name="colB" value="0"></td>
</tr>
</table>
</div>
</td>
<td width="8"></td>
<td>
<table border="0" cellPadding="0" cellSpacing="0">
<tr>
<td>
<div class="container">
<table border="0" cellPadding="0" cellSpacing="0" id="MainColor" onclick="sel_color('RGB')" onmouseover="sel_colorover('RGB')" onmouseout="sel_colorout('RGB')">
<script language="JavaScript">
<!--
function wc(r, g, b, n)
{
r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15; document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=10 width=6></TD>');
}var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0); for(i = 0; i < 16; i ++)
{
document.write('<TR>');
for(j = 0; j < 30; j ++)
{
n1 = j % 5;
n2 = Math.floor(j / 5) * 3;
n3 = n2 + 3; wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
(cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
(cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
} document.writeln('</TR>');
}
//-->
</script>
</table>
</div>
</td>
<td width="8"></td>
<td>
<div class="container">
<table border="0" cellPadding="0" cellSpacing="0" id="GrayTable" onclick="sel_color('GRAY')" onmouseover="sel_colorover('GRAY')" onmouseout="sel_colorout('GRAY')">
<script language="JavaScript">
<!--
for(i = 240; i >= 0; i -= 6)
document.write('<TR BGCOLOR=#' + ToHex(i) + ToHex(i) + ToHex(i) + '><TD TITLE=' + i + ' height=4 width=20></TD></TR>');
//-->
</script>
</table>
</div>
</td>
<td width="5">
<div id="col" style="position:absolute;width:5px; height:9px;z-index:1">
<img src="images/sel_curr.gif" width="5" height="9">
</div>
</td>
</tr>
<tr>
<td colspan="4">
<table border="0" cellPadding="2" cellSpacing="3" width="100%">
<tr>
<td align="middle" rowSpan="2">
<table border="1" class="container" cellPadding="0" cellSpacing="0" height="30" id="ShowColor" bgcolor="#000000" width="50">
<tr><td></td></tr>
</table>
颜色|纯色
</td>
<td rowSpan="2" nowrap>
基色: <span id="RGB">#000000</span><br>
代码: <input id="SelColor" size="7" value="#000000">
</td>
<td>
<input type="submit" id="Ok" value="确定" onclick="return_color()">
</td>
</tr>
<tr>
<td><input type="button" onclick="window.close()" value="取消"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</body>
</html>
可以在var return_value = showModalDialog("set_color.html", "", "dialogWidth:29em; dialogHeight:17.5em; status:0");
后用 if(typeof(return_value ) == "undefined"){
自己的处理(反正他取消了很容易做的)
}