JavaScript产生随机颜色

             //获取rgb类型的颜色  IE7不支持
            function randomColor(){
                var r = Math.floor(Math.random()*256);
                var g = Math.floor(Math.random()*256);
                var b = Math.floor(Math.random()*256);
                return "rgb("+r+","+g+","+b+")";
            }
             
            //获取十六进制颜色
            function randomColor1(){
                var r = Math.floor(Math.random()*256);
                var g = Math.floor(Math.random()*256);
                var b = Math.floor(Math.random()*256);
                 
                if(r < 16){//当小于16时,只有一位数,所以给它前面串联一个0
                    r = "0"+r.toString(16);
                }else{
                    r = r.toString(16);
                }
                if(g < 16){
                    g = "0"+g.toString(16);
                }else{
                    g = g.toString(16);
                }
                if(b < 16){
                    b = "0"+b.toString(16);
                }else{
                    b = b.toString(16);
                }
                 
                return "#"+r+g+b;
            }
             
            /*
                进制转换
                Number.toString(2);
                转换成2\8\10\16
                 
            */
             
            function test(){
                //console.log(new Number(15).toString(16));
            }
            //test();