<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>16 binary color value turn RGB</title> <style> *{margin:0;padding:0;font-family:' Microsoft Yahei '}. Replace{width:400px;Height:210px;margin:0 Auto;Padding-top:40px;}. Title{text-align:Center;Display:Block}form{width:200px;margin:30px Auto;}input{Outline:None;}input[type= "button"]{cursor:Pointer;} </style> <Script> functionHextor (h) {returnparseint ((Cuthex (h)). Substring (0, 2), -) } functionHextog (h) {returnparseint ((Cuthex (h)). Substring (2, 4), -) } functionHextob (h) {returnparseint ((Cuthex (h)). Substring (4, 6), -) } functionCuthex (h) {returnH.charat (0) == "#" ?h.substring (1, 7): H}functionSetbgcolorbyid (ID, scolor) {varElems; if(document.getElementById) {if(Elems=document.getElementById (ID)) { if(elems.style) Elems.style.backgroundColor=Scolor; } } } </Script> </Head> <Body> <Divclass= "Replace"> <spanclass= "title">JavaScript native 16 binary color value to RGB value</span> <formname= "RGB"> <inputvalue= "FFFFFF"maxlength= "7"size= "+"name= "Hex" /> <inputonclick= "Setbgcolorbyid (' colorsample ', this.form.hex.value); This.form.r.value=hextor (This.form.hex.value); This.form.g.value=hextog (This.form.hex.value); This.form.b.value=hextob (This.form.hex.value); "value= "Convert"type= "button"name= "BTN"/> <BR/><BR/>R:<inputstyle= "width:30px"size= "3"name= "R" />G:<inputstyle= "width:30px"size= "3"name= "G" />B:<inputstyle= "width:30px"size= "3"name= "B" /> </form> </Div></Body></HTML>
JavaScript 16 binary color value turn RGB