Cascading Style Sheets Tutorial

CSS + javascript dialog box of colors

  Color.js color dialog according to the actual situation of the implementation of changes setcolor function 

  / / JavaScript Document 
  Function getcolor () 
  (… 
  Var s = ""; 
  S +=("< div class = 'color'>"); 
  S +=("< div style = 'height: 40px ;'>"); 
  S +=("< table> <tr> <td> <div id='ccc' style='width:100px;height;40px;background-color:#000000;'> </ div> "); 
  S +=("</ td> <td> <input type='text' id='cc' size='10' value='#000000'/> </ td> </ tr> </ table> ") ; 
  S +=("</ div> "); 
  S +=("< div class = 'bcolor'> <table cellspacing='0' cellpadding='0'> <tr> "); 
  For (var r = 0; r <= 15, r + = 3) 
  (… 
  If (r = 9) 
  S +=("</ tr> <tr> "); 
  S +=("< td> "); 

  S +=("< table cellspacing ='0 'cellpadding ='0'>"); 
  For (var b = 0; b <= 15; b + = 3) 
  (… 
  S +=("< tr> "); 
  For (var g = 0; g <= 15; g + = 3) 
  (… 
  / / If (b == 9) s +=("</ tr> <tr> "); 
  Var rr = r.toString (16); 
  Rr rr + =; 
  Var bb = b.toString (16); 
  Bb + = bb; 
  Var gg = g.toString (16); 
  Gg + = gg; 
  S + = "<td class = 'ctd' onmousemove = 'movecolor ("#"+ rr + gg + bb +"")'"; 
  S + = "onclick = 'setcolor ("#"+ rr + gg + bb +"")' style =' border: 1px solid # 000"; 
  S + = "background-color: #" + + gg + bb rr +";'>"; 
  S +="</ td> "; 

  ) 
  S +=("</ tr> "); 
  ) 
  S +=("</ table> "); 
  S +=("</ td> "); 


  ) 
  S +=('</ tr> </ table> </ div> </ div> '); 
  Return s; 
  ) 
  Function getobj (id) 
  (… 
  Return document.getElementById (id); 
  ) 
  Function movecolor (color) / / Mouse over the operation of a certain color 
  (… 
  Getobj ( "ccc"). Style.backgroundColor = color; 
  Getobj ( "cc"). Value = color; 

  ) 
  Function setcolor (color) / / mouse click after the operation of a color 
  (… 
  Getobj ( "colordiv"). Style.backgroundColor = color; 
  Getobj ( "cccc"). Style.display = "none"; 
  ) 

  Test.html test 

<html>
<head>
  <script Type="text/javascript" src="color.js"> 
  </ Script> 
  <style Type="text/css"> 
  . Color (border: 1px solid # 9999FF; width: 300px;) 
  . Bcolor (background-color: # e5e5ef; border: 1px solid # eba8ff; cursor: hand;) 
  . Ctd (margin: 0; padding: 0; height: 15px; width: 15px;) 

  </ Style> 
  <script Type="text/javascript"> 
  Function c_click () ( 
  Var e = window.event; 
  Getobj ( "cccc"). InnerHTML = getcolor (); 
  Getobj ( "cccc"). E.x style.left = + "px"; 
  Getobj ( "cccc"). E.y style.top = + "px"; 
  Getobj ( "cccc"). Style.display = ""; 
  ) 

  </ Script> 
  </ Head> 
  <button Onclick="c_click()"> color </ button> 
  <div Id="cccc" style="display:none; border-width:0; position:absolute; z-index:1000; width:200px; height:180px; "> </ div> 
  <div Style="width:80px;height:30px;backgroundColor=#000" id="colordiv"> </ div> 

  </ Body> 
  </ Html> 

  What needs to be modified or do you have a better method of the implementation of the comments requested 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • DZone

Tags: css javascript

Releated Posts

  • Css + javascript drop-down menu
  • JavaScript build with the CSS + page tab
  • How to use Javascript dropdown menu with CSS Generation
  • Css learning and web-javascript biographical notes on the production of a
  • VS.Net2003 new Javascript, CSS, and other documents attention should be paid to coding problems

This entry was posted on Thursday, January 24th, 2008 at 12:00 am and is filed under CSS Tutorial. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« CSS expression of alternative treatments
The CSS Hack …… »

Leave a Reply

  • Categories

    • CSS Properties (491)
    • CSS Tutorial (1154)
    • CSS Tutorial By Examples (1201)
    • Css+Div Web Design (3274)
    • Xhtml and Web Design (1797)
  • Archives

    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
  • Pages

    • About us

Cascading Style Sheets Tutorial