Js background constantly changing code-QQ space code

Source: Internet
Author: User
Tip: you can modify some code before running

Js background constantly changing code-QQ space code<SCRIPT LANGUAGE="JavaScript">IE = (document. all );<!--判断是否是IE浏览器-->If (IE) {var chidc = new Array ();<!--各个表格的背景色-->Var hexc = new Array ('0', '1', '2', '3', '4', '5', '6', '7 ', '8', '9', 'A', 'B', 'C', 'D', 'e', 'F ');<!--用于十-十六进制的转换-->Var chidn = new Array (100,70, 40 );<!--初始化-->Var step = new Array (10, 10, 10 );<!--变化步长-->Var chway = new Array (step [0], step [1], step [2]);<!--变化步长-->Var tone = new Array (1, 1 );<!--平衡变量-->Function chcol () {for (I = 0; I <3; I ++) {chidn [I] + = chway [I];<!--三个表格分别按照设定的步长增长,最大值不能超过255-->If (chidn [I]> = 255) {chidn [I] = 255; chway [I] =-step [I];<!--如果超过了,则改为同样步长的递减-->} Else if (chidn [I] <= 40 ){<!--最小值不能低于40-->Chidn [I] = 40; chway [I] = step [I]; tone [I]> = 3? Tone [I] = 1: tone [I] ++;<!--tone数组中的值不超过3-->} Col1 = hexc [Math. floor (chidn [I]/16)];<!--转换为十六进制表示-->Col2 = hexc [chidn [I] % 16]; tored = ''; toblue =''; for (j = 1; j<tone[i]; j++) tored+='00'; <!--分别对红色分量和蓝色分量进行处理以实现渐变效果-->For (j = 3; j> tone [I]; j --) toblue + = '00'; chidc [I] = '#' + tored + col1 + col2 + toblue;<!--将值赋给chidc-->Td = eval ('document. all. Chcol' + I); td. style. backgroundColor = chidc [I];<!--设定第i个表格的背景色-->} SetTimeout ('chcol () ', 100 );<!--延时0.1s-->}}</script><table cellspacing=2 cellpadding=0 bgcolor=#999999 width=400><tr><td width=33% align=center id=chcol0 name=id=chcol0><font color=white>JavaScript Forum</td><td width=33% align=center id=chcol1 name=id=chcol0><font color=white>JavaScript special effects</td><td width=33% align=center id=chcol2 name=id=chcol0><font color=white>JavaScript learning</td></tr></table><SCRIPT LANGUAGE="JavaScript">Chcol ();<!--调用chcol函数--></script><!--本例实现了渐变色表格的功能--><!--重点在于颜色的配置,本例是通过chcol函数中的for循环来实现的--><!--定义了多个变量来表示颜色的变化步长、绝对值等--><!--每种颜色显示0.1秒-->
Tip: you can modify some code before running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.