Today I learned the Window object, followed by a simple web color picker demo, come out and share with you.
Main Page code:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> Color Picker </title>
<body>
<script language= "JavaScript" >
function Colorpick (file) {
var rtn=window.showmodaldialog ("color.html", "" "," DIALOGWIDTH:225PX;DIALOGHEIGHT:170PX;STATUS:NO;HELP:NO; Scrolling=no;scrollbars=no; ")
if (RTN! = null)
File.style.background=rtn;
return;
}
</script>
<input type= "text" name= "color" id= "Color" size= "3" readonly= "yes" style= "" >
</body>
Color Picker "color.html" page code:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>color</title>
<body>
<script language= "JavaScript" >
var h=new Array (6);
H[0]= "FF";
H[1]= "CC";
h[2]= "99";
H[3]= "66";
h[4]= "33";
h[5]= "00";
function Action (RGB) {
Parent.window.returnvalue= "#" +RGB; Returns the value of the color to the parent window.
Window.close ();
}
function Mcell (r,g,b) {
document.write (' <td bgcolor= ' # ' +r+g+b+ ' > ');
document.write (' <a href= ' # ' onclick= ' action (\ ' + (r+g+b) + ' \ ') ' > ');
document.write (' ');
document.write (' </a> ');
document.write (' </td> ');
}
function Mtr (r,b) {
document.write (' <tr> ');
for (Var i=0;i<6;++i) {
Mcell (R,H[I],B);
}
document.write (' </tr> ');
}
function Mtable (B) {
document.write (' <table cellpadding=0 cellspacing=0 border=0> ');
for (var i = 0; i < 6; ++i) {
MTR (H[i], B);
}
document.write (' </table> ');
}
function Mcube () {
document.write (' <table cellpadding=0 cellspacing=0 border=0><tr> ');
for (var i = 0; i < 6; ++i) {
if (i%3==0) {
document.write (' <tr> ');
}
document.write (' <td bgcolor= ' #FFFFFF > ');
Mtable (H[i]);
document.write (' </td> ');
}
if (i%3==0) {
document.write (' </tr> ');
}
document.write (' </tr></table> ');
}
Mcube ();
</script>
</body>
JavaScript source JS Implementation of a simple web color picker