Color picker (IE only) : Color Chooser « GUI Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » GUI Components » Color Chooser 
Color picker (IE only)
 
<!--
##############################################
#         WebFX Dynamic Webboard 2.0         #
#       By Emil A Eklund (eae@eae.net)       #
#      and Erik Arvidson (erik@eae.net)      #
#           http://webfx.eae.net             #
#              April 131999                #
##############################################
# Feel free to use this script for personal  #
# and non profit web sites, as long as you   #
# are giving us credits for it, in other     #
# words, not removing nor modifying this     #
# notice in any of the files it appears in   #
##############################################
#  For commercial use contact Emil or Erik   #
##############################################
-->

<html>
<head>
<style> 
 <!--
 body  {background : buttonface; margin: 5; margin-top: 2;
     border-top: solid buttonhighlight;
    border-left: solid buttonhighlight;
    border-right: solid buttonshadow;
    border-bottom: solid buttonshadow;}
td    {width : 10px; height : 10px; font-size : 1px; cursor: hand;}
 -->
 </style>
<script type="text/javascript">
<!--

var ie5 = document.getElementById != null;

function doOver() {
  var el = window.event.srcElement;
  bgc = el.style.backgroundColor;

  if (bgc != "") {
    el.style.borderTopColor = "white";
    el.style.borderLeftColor = "white";
    el.style.borderRightColor = "black";
    el.style.borderBottomColor = "black";
  
    colorBox.style.backgroundColor = bgc;
    colorName.innerHTML = bgc;
  }
}
function doClick() {
  bgc = window.event.srcElement.style.backgroundColor;
  window.event.srcElement.style.borderColor = bgc;
  if (bgc != "") {
    window.external.raiseEvent("colorchange", bgc);
  }
}
function doOut() {
  var el = window.event.fromElement;
  bgc = el.style.backgroundColor;

  if (bgc != "") {
    el.style.borderColor = bgc;
  }
}
window.onload = init;

function init() {
  fixTitle();
}

function fixTitle() {
  document.title = parent.document.title;
}

var colors = new Array("white""snow""floralwhite""ghostwhite""whitesmoke"
"ivory""oldlace""linen""seashell""antiquewhite","papayawhip","peachpuff",
"beige","bisque","blanchedalmond","cornsilk","lemonchiffon","lightyellow",
"lightgoldenrodyellow","palegoldenrod",
"wheat","moccasin","navajowhite","khaki","burlywood","tan","darkkhaki",
"gold","yellow","goldenrod","darkgoldenrod","peru","saddlebrown","sienna","chocolate","brown",
"mintcream""aliceblue","azure","lightcyan","lightblue","powderblue",
"lightskyblue","skyblue","deepskyblue",
"cyan","aqua","aquamarine","paleturquoise","turquoise","darkturquoise","mediumturquoise",
"darkcyan","royalblue","cornflowerblue","dodgerblue","blue","mediumblue","darkblue","midnightblue","navy",
"darkslateblue","lightsteelblue","steelblue","cadetblue","slateblue","mediumslateblue",
"indigo","purple","darkmagenta","darkorchid","mediumorchid","blueviolet","mediumpurple","darkviolet","magenta",
"fuchsia","plum","thistle","violet","orchid","deeppink","hotpink",
"mediumvioletred","palevioletred",
"lavender","lavenderblush","mistyrose","pink","lightpink","salmon","lightsalmon",
"coral","darksalmon","sandybrown","orange","orangered","tomato",
"darkorange","crimson","red","firebrick","maroon","darkred","indianred","rosybrown","lightcoral",
"honeydew","springgreen","mediumspringgreen",
"palegreen","chartreuse","lawngreen","greenyellow",
"lime","lightgreen","limegreen",
"mediumaquamarine","lightseagreen","teal","mediumseagreen","seagreen","darkseagreen",
"yellowgreen","olive","olivedrab",
"forestgreen","green","darkgreen""darkolivegreen",
"lightslategray","slategray","darkslategray",
"gainsboro","lightgrey","silver","darkgray","gray","dimgray","black");

var sysColors = new Array("activeborder","activecaption","appworkspace","background","buttonface",
"buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext",
"inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext",
"scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window",
"windowframe","windowtext");

function writeRow(ar) {
  var cells = 15;
  var str = "";
  
  for (var i=0; i<ar.length; ) {
    str += "<tr>"
    for (var j=0; j<=cells && i<ar.length; j++) {
      str += "<td style='background-color: " + ar[i"; border: 1px outset " + ar[i";'>";
      str += "&nbsp;</td>\n";
      i++;
    }
    str += "</tr>\n";
  }
  return str;
}  
//-->
</script>
</head>
<body>

<table cellspacing="0" 
       cellpadding="0" 
       onmouseover="doOver()" 
       onmouseout="doOut()" 
       onclick="doClick()" 
       style="width: 180;">
  <tr>
    <td colspan="15" 
        style="font-family: verdana, helvetica; font-size: 9px; color: button-text; cursor: default; height: 15px;">
        <nobr>Named Colors:</nobr>
    </td>
</tr>
<script>
  document.write(writeRow(colors));
</script>
</table>
<table cellspacing="0" 
       cellpadding="0" 
       onmouseover="doOver()" 
       onmouseout="doOut()" 
       onclick="doClick()" 
       style="width: 180;">
<hr>
<script>
  document.write(writeRow(sysColors));
</script>
</table>
<hr>
<table>
  <tr>
    <td id="colorBox" style="border: 1px inset window;  width: 20; height: 20; font-size: 2px; cursor: default;">&nbsp;</td>
    <td id="colorName" style="border: 0; font-family: verdana, helvetica; font-size: 9px; color: button-text; cursor: default;">ColorName</td>
  </tr>
</table></body></html>


           
         
  
Related examples in the same category
1. JavaScript ColorPicker
2. Text foreground and background color picker
3. Color Picker (Windows style)
4. Color chooser in JavaScript
5. DHTML Color Picker
6. Farbtastic: jQuery color picker plug-in
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.