کد
<!--***********|www.gpgtools.blogsky.com|*********** --> <!-- Start of Fade In and Out JavaScript--> <!-- Place this entire script into a new webpage and then work off the example. Do not --> <!-- try to incorporate into an existing webpage, else you may disrupt the Script --> <!-- Script supplied with CoffeeCup HTML Editor --> <!-- www.coffeecup.com --> <HTML> <HEAD> <style type="text/css"> <!-- #fadeMe01 { position: absolute; visibility: visible; width: 410px } #fadeMe02 { position: absolute; visibility: visible; width: 400px } .content { font: 16pt Verdana, Arial, Helvetica; width: 400px; text-align: center } .content1 { font: 16pt Verdana, Arial, Helvetica; width: 400px; text-align: center } .small { font: 6pt Verdana, Arial, Helvetica; width: 400px; text-align: center } b { font-weight: bold } a { text-decoration : none } // --> </style> <script type="text/javascript" language="javascript"> <!-- var idme=908601; var convert = new Array(); var hexbase = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"); var value=0; var rgb; for (x=0; x<16; x++) for (y=0; y<16; y++) { convert[value] = hexbase[x] + hexbase[y]; value++; } var timerID = null, timerRunning = false; function stopClock(){ if(timerRunning) clearTimeout(timerID) timerRunning = false } var layers = document.layers; var style = document.all; var both = layers || style; if (layers) { layerRef = 'document.layers'; styleRef = ''; } if (style) { layerRef = 'document.all'; styleRef = '.style'; } function moveLayer(obj, topx, leftx) { if (both) { eval(layerRef + '["'+obj+'"]' + styleRef + '.top = topx'); eval(layerRef + '["'+obj+'"]' + styleRef + '.left = leftx'); } } var s1, s2, s3, s2r, s2g, s2b, smallest; function hexToDec(hex) { var value=0; while (true) { if (convert[value] == hex) break; value++; } return value; } function writeOn(obj, str) { if (layers) with (document[obj]) { document.open(); document.write(str); document.close(); } if (style) { eval(obj+'.innerHTML= str'); } } function changeColor(obj, str, rgb1, speed, counter) { if (counter < smallest) { stopClock(); if (layers) with (document[obj]) { document.open(); document.linkColor = rgb1; document.fgColor = rgb1; document.write(str); document.close(); } if (style) { eval(obj+'.document.linkColor= rgb1'); eval(obj+'.innerHTML= "<font color="+rgb1+">"+str+"<\/font>"'); // eval(layerRef + '["'+obj+'"]' + styleRef + '.color= rgb1'); } s2r+=s1; s2g+=s2; s2b+=s3; tempR = Math.round(s2r); tempG = Math.round(s2g); tempB = Math.round(s2b); if (tempR <= 0) tempR = 0; if (tempG <= 0) tempG = 0; if (tempB <= 0) tempB = 0; if (tempR >= 255) tempR = 255; if (tempG >= 255) tempG = 255; if (tempB >= 255) tempB = 255; rgb1 = convert[tempR] + convert[tempG] + convert[tempB]; counter++; timerID = setTimeout('changeColor("'+obj+'", "'+str+'", "'+rgb1+'", '+speed+', '+counter+')', speed); timerRunning = true; } } function fadeText(obj, str, rgb1, rgb2, speed, step) { var r1, g1, b1, r2, g2, b2; for (cnt=1; cnt<=2; cnt++) { eval('r'+cnt+' = hexToDec(rgb'+cnt+'.slice(0,2));'); eval('g'+cnt+' = hexToDec(rgb'+cnt+'.slice(2,4));'); eval('b'+cnt+' = hexToDec(rgb'+cnt+'.slice(4,6));'); } with (Math) { s2r = r1; s2g = g1; s2b = b1; s1 = abs(r1 - r2); s2 = abs(g1 - g2); s3 = abs(b1 - b2); if (s1 > s2 && s1 > s3) { smallest = s1; } else if (s2 > s1 && s2 > s3) { smallest = s2; } else { smallest = s3; } s1 = (s1 == 0) ? 0 : s1/smallest; s2 = (s2 == 0) ? 0 : s2/smallest; s3 = (s3 == 0) ? 0 : s3/smallest; s1*=step; s2*=step; s3*=step; if (r1 > r2) { s1 = -s1; } if (g1 > g2) { s2 = -s2; } if (b1 > b2) { s3 = -s3; } smallest= Math.round(smallest/step); } if (both) { changeColor(obj, str, rgb1, speed, 0); } else { document.write("Err. for some reason you tried viewing this page with a browser that doesn`t support javascript/CSS block support"); } } function getMid() { tvAgent = navigator.userAgent; if (layers) { maxX = innerWidth; maxY = innerHeight; } if (style) { maxX = document.body.clientWidth; maxY = document.body.clientHeight; } if (tvAgent.indexOf("WebTV") != -1) { maxX = 544; maxY = 378; } midX = maxX/2; midY = maxY/2; } function layout() { getMid(); moveLayer('fadeMe01', midY-50, midX-200); fadeText("fadeMe01", "<span class=content>NOW PRESENTING</span><div class=small>by popular demand</div>", "000000", "CCCCCC", 10, 2); setTimeout('fadeText("fadeMe01", "<span class=content>FADE IN AND OUT JavaScript</span><div class=small>A neat JavaScript</div>", "CCCCCC", "000000", 10, 4)',8000); setTimeout('fadeText("fadeMe01", "<div class=small>A</div><span class=content>It is COOL</span>", "000000", "CCCCFF", 10, 2)',12000); setTimeout('fadeText("fadeMe01", "<div class=small>A</div><span class=content>Easy to Use</span>", "CCCCFF", "000000", 10, 4)',20000); setTimeout('moveLayer("fadeMe01", midY-100, midX-200)',24000); setTimeout('moveLayer("fadeMe02", midY-60, midX-200)',24000); setTimeout('fadeText("fadeMe01", "<span class=content>This line could be Sentence Line 1.</span>", "000000", "CCCCFF", 10, 4)',26000); setTimeout('fadeText("fadeMe02", "<span class=content>Sentence Line 2.</span>", "000000", "9999FF", 10, 4)',32000); setTimeout('fadeText("fadeMe01", "<span class=content>Sentence Line 3.</span>", "CCCCFF", "FF0000", 10, 4)',36000); setTimeout('fadeText("fadeMe02", "<span class=content>Imagine the envy your friends will feel.</span>", "9999FF", "99FF33", 10, 4)',40000); setTimeout('fadeText("fadeMe02", "<span class=content>Sentence Line 5.</span>", "99FF33", "CCCCCC", 10, 4)',44000); setTimeout('fadeText("fadeMe02", "<span class=content>You can now make neat looking text displays.</span>", "CCCCCC", "000000", 10, 4)',48000); setTimeout('fadeText("fadeMe02", "<span class=small>Sentence Line 7.</div>", "000000", "CCCCCC", 10, 4)',52000); setTimeout('fadeText("fadeMe01", "<span class=content>-END-</div>", "000000", "FF0000", 10, 4)',57500); } // --> </script> </HEAD> <BODY BGCOLOR="#000000" text="#CCCCCC" link="#FFFFFF" vlink="#FFFFFF" onload="layout()"> <div id=fadeMe01></div> <div id=fadeMe02></div> <noscript> Silly! you'll need to have javascript enabled and you must have <a href="http://www.microsoft.com/">Internet Explorer 4</a> or <a href="http://developer.netscape.com">Netscape Navagitor 4</a> or <a href="http://developer.webtv.net">WebTV</a>(?) for this script to work. </noscript> </BODY> </HTML> <!-- End of Fade In and Out JavaScript--> <!--***************| www.gpgir.org|************** -->