Ajax yellow fade with javascript
时间:2010-10-15 来源:李晴川
代码
1 /**
2 * @author Admin
3 */
4 function fadeUp(element,red,green,blue)
5 {
6 if(element.fade)
7 {
8 clearTimeout(element.fade);
9 }
10 element.style.backgroundColor = "rgb("+red+","+green+","+blue+")";
11 if(red==255&&green==255&&blue==255)
12 return;
13 var newRed = red+Math.ceil((255-red)/10);
14 var newGreen = green+Math.ceil((255-green)/10);
15 var newBlue = blue+Math.ceil((255-blue)/10);
16
17 var repeat = function()
18 {
19 fadeUp(element,newRed,newGreen,newBlue);
20 }
21 setTimeout(repeat.100);
22 }
调用实例:
代码
1 function parseResponse(request)
2 {
3 if(request.readyState==4)
4 {
5 if(request.status == 200 || request.status == 304)
6 {
7 var details = document.getElementById("details");
8 details.innerHTML= requestText;
9 fadeUp(details,255,255,153);//yellow to white
10 }
11 }
12 }
More samples,see http://www.axentric.com/aside/fat/
相关阅读 更多 +