Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,344 members, 7,957,915 topics. Date: Wednesday, 25 September 2024 at 01:02 AM |
Nairaland Forum / Science/Technology / Webmasters / [javascript ]- A Script To Generate Random Colors (1452 Views)
Free Script To Check Domain Availability / How Can I Get A Script For Building A Forum On My Website / Php Random Script To Generate Pin No. (2) (3) (4)
(1) (Reply)
[javascript ]- A Script To Generate Random Colors by kambo(m): 5:53pm On Sep 12, 2006 |
what does this script do? -------------------------------- suppose to help u make better color choices by generating a 2 random colors , rendering text in color#1 and background in color #2. and vice versa . also rendering sample texts in both random colors also. okay, its not photoshopand i aint no pro coder gat a 1 mnth of javascript practice,but is it useful?, or u still thinking red,blue,yellow ,green - like i was before hacking this together. ---------------------------------------------------------------------------------------------------- here's the code code block: save as dot html ".html e.g colorscript.html' color are generated randomly,and the colors' hex codes also are rendered. copy code within the <html></html> tags. --------------------------------------------------------------------------------------------------------------- <html> <head> <script> // autogenerated hash colors var range= new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','f') var hash ="#"; var col = function(){ var scope = range.length-1; var start=0; rndm = function(){ var hashc =""; for(x=0;x<6;x++){ var make = Math.floor(Math.random()*scope+start); hashc += range[make]; } return hashc; } var mxc = rndm(); return hash+mxc; } /////////////////////////////////// end of autocolor method/// function testc(){ var t = document.getElementById("para" var xl = document.getElementById("tall" var reps = document.getElementById("tall" var bgbx = document.getElementById("bgk" var tbx = document.getElementById("txtk" var look = col(); var bgc = col(); t.innerHTML="<b style='background-color:"+look+";font-size:20px;color:"+bgc+"'>"+"Background Color= 'LL' . textcolor= 'AA' </b>"; xl.innerHTML="<BR><h2 style='background-color:"+bgc+";font-size:30px;color:"+look+";'><pre>BGC = AA "+ "TEXT = LL</PRE>"+ "code</h2>" // combine color and display var stn = document.getElementById("stn1" stn.innerHTML ="<br><h3 style='color:"+look+";font-size:24px;'>TEXT I: LL"+ "</h3>"; var terd = document.getElementById("again" terd.innerHTML="<b style='font-size:21px;color:"+bgc+";'>TEXT II :AA</b>"; //set tbx . bgbx code tbx.value=look; bgbx.value = bgc; } </script> </head> <body> <fieldset> <hr> <b style="font-size:37px;background-color:yellow;color:black;"><center>cOLOR mIx , :</center></b> <hr> </fieldset> <p id="para"> </P> <fieldset> <p><h2 id="tall"><hr> ITS ALL ABOUT COLOR!!</h2> <b id="stn1">stand alone text :</b> <code id="again"> SAMPLE TEXT </code> </p> <hr> <p> <button onclick="testc()">change color</button></p> </fieldset> <p><center> <h3><strong> <u> HEX CODE :</u></strong></h3><b><font size="6">'AA:':</font></b> <input type = "text" id="bgk" value="" size="15" readonly=""></center></p> <p><center> <code><bold>HEX CODE.:</bold></code><P> <b><font size="6">'LL:' :</font></b><input type ="text" id="txtk" value="" size="15" readonly=""></p></center></p> </body> </html> <!-------stop copyhere-------> |
(1) (Reply)
Web Masters' Professionalism In Nigeria / My Blog In Hausa Language / Flat-sql Database Engine - An Ultra-light Weight Database Engine
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14 |