爱易网
IT新闻
IT新闻
爱易资讯
网站搭建
云虚拟主机教程
云服务器教程
Apache教程
IIS教程
Nginx教程
网站策划
站长文章
推广教程
淘宝客教程
网页设计
HTML教程
XHTML教程
CSS教程
HTML5教程
CSS3教程
JavaSript基础
JQuery教程
Node.js教程
前端技术
Ajax教程
Js特效
Xml教程
平面设计
页面UI设计
photoshop教程
程序开发
AI人工智能
Asp教程
Php教程
Asp.Net教程
Net Core教程
C#教程
Java教程
Jsp教程
开发技术
微信小程序教程
Uniapp开发教程
微信公众号开发
Andriod教程
IOS教程
DOS教程
Python教程
Docker教程
Windows Container教程
数据库
MSSQL教程
MySQL教程
Redis教程
Access教程
Oracle教程
数据库教程
操作系统
Linux教程
Windows教程
MAC教程
Cisco教程
交换机教程
防火墙教程
搜索
爱易网页
JS特效
背景颜色随机产生
背景颜色随机产生
日期:2014-05-18 浏览次数:22139 次
欢迎光临爱易网网页脚本特效中心,点击运行按钮演示特效:
以下是程序代码
要完成此效果需要两个步骤 第一步:把如下代码加入到<head>区域中 <SCRIPT LANGUAGE="JavaScript"> <!-- color=new Array("0","3","6","9","C","F"); speed=250; document.bgColor="FFFFFF"; bg=new Array("FFFFFF","FFFFFF","FFFFFF"); function begin() { document.form.col1.value=" X "; document.form.col2.value=" X "; document.form.col3.value=" X "; i=0; roll(speed); } function roll(speedB) //轮子滚动 { if (document.form.col1.value==" X ") { document.form.c1.value=document.form.b1.value; document.form.b1.value=document.form.a1.value; document.form.a1.value= color[Math.round(Math.random()*10)%6]+ color[Math.round(Math.random()*10)%6]; //利用随机函数产生轮子上的颜色值 } if (document.form.col2.value==" X ") { document.form.c2.value=document.form.b2.value; document.form.b2.value=document.form.a2.value; document.form.a2.value= color[Math.round(Math.random()*10)%6]+ color[Math.round(Math.random()*10)%6]; } if (document.form.col3.value==" X ") { document.form.c3.value=document.form.b3.value; document.form.b3.value=document.form.a3.value; document.form.a3.value= color[Math.round(Math.random()*10)%6]+ color[Math.round(Math.random()*10)%6]; } setTimeout("roll("+speedB+")",speedB); } function stop(col) //轮子停止滚动 { if (col==1) {document.form.col1.value=" ";i++;} if (col==2) {document.form.col2.value=" ";i++;} if (col==3) {document.form.col3.value=" ";i++;} if (i==3) { bg[0]=document.form.a1.value+ document.form.a2.value+ document.form.a3.value; bg[1]=document.form.b1.value+ document.form.b2.value+ document.form.b3.value; bg[2]=document.form.c1.value+ document.form.c2.value+ document.form.c3.value; speedB=500000;roll(speedB); } } function view(letter) //颜色预览 { document.bgColor=bg[letter]; document.form.color.value="#"+bg[letter]; } --> </script> 第二步:把如下代码加入到<body>区域中 <form name="form"> <table cellpadding=2 border=1 align="center"> <tr><td align=center> <input type=text name="a1" size=3 onFocus="this.blur()" value=" "> <input type=text name="a2" size=3 onFocus="this.blur()" value=" "> <input type=text name="a3" size=3 onFocus="this.blur()" value=" "> <input type=button onClick="view(0)" value="预览"><br> <input type=text name="b1" size=3 onFocus="this.blur()" value=" "> <input type=text name="b2" size=3 onFocus="this.blur()" value=" "> <input type=text name="b3" size=3 onFocus="this.blur()" value=" "> <input type=button onClick="view(1)" value="预览"><br> <input type=text name="c1" size=3 onFocus="this.blur()" value=" "> <input type=text name="c2" size=3 onFocus="this.blur()" value=" "> <input type=text name="c3" size=3 onFocus="this.blur()" value=" "> <input type=button onClick="view(2)" value="预览"><br> <input type=button onClick="stop(1)" value=" X " name="col1"> <input type=button onClick="stop(2)" value=" X " name="col2"> <input type=button onClick="stop(3)" value=" X " name="col3"> </td> <td valign=middle align=center> <input type=button onClick="begin()&quo
上一篇:狡猾的按钮特效
下一篇:用按钮来实现背景色的闪烁
免责声明:
本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
相关资料
更多>
亚马逊宣布新春大促策略 欲打造另一个"黑五"
苹果CEO抱歉解读:是战略而非“屈服”
打车软件竞争白热化:有冷兵器时代意味
运营商补贴减少 国内通信业拐点逼近
黑莓高管:黑莓能作为家“小众公司”活下来
360涉足搜索范围 百度市场份额面临应战
独立工具APP:为亿级用户的商业化而愁
美国政府关门可能影响去哪儿等公司IPO
京东封杀财付通:终极目标是电商生态圈
推荐阅读
更多>
诺基亚若没加入微软,只不过是另一个HTC而已
从WPS到office365,中国企业能否赶超美国?
首家国有独资P2P平台上线 或预示政策日渐明朗
三星维修新规:Galaxy S4主板进水也收费修
微软很“捉急”:补贴Win8 重加末尾按钮
亚马逊推特价闪购纪念入华十周年 总裁一职仍空缺
苏宁双线同价遇难题:第一个吃螃蟹不轻松
马云寄厚望于物流 “菜鸟”行情暂难持续
小米打响手机价格战 为米3铺路或另有所图
打车软件竞争白热化:有冷兵器时代意味
刘强东向总理建言:打击有组织有规模的售假商家
传4G牌照国庆节前后发放 TD-LTE制式优先
前苹果顾问批判iPhone命名:不应加S
人们为什么总愿尝试新社交网络?
三大运营商合建铁塔公司真相:未涉及电信业重组
360涉足搜索范围 百度市场份额面临应战
都是300元内 乐视盒子与小米盒子对比体验
说说这一个月的赌球输了多少
英特尔技术高管离任 电视业务或受影响
苹果股价突破100美元大关:投资者看好iPhone 6