Скрипт летающих тарелок
<HEAD> <! > <! > <!-- Begin var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4)); var _all = ''; var _style = ''; var wwidth, wheight; var ydir = '++'; var xdir = '++'; var id1, id2, id3; var x = 1; var y = 1; var x1, y1; if(!isNS) { _all='all.'; _style='.style'; } function getwindowsize() { clearTimeout(id1); clearTimeout(id2); clearTimeout(id3); if (isNS) { wwidth = window.innerWidth - 55; wheight = window.innerHeight - 50; } else { wwidth = document.body.clientWidth - 55; wheight = document.body.clientHeight - 50; } id3 = setTimeout('randomdir()', 20000); animate(); } function randomdir() { if (Math.floor(Math.random()*2)) { (Math.floor(Math.random()*2)) ? xdir='--': xdir='++'; } else { (Math.floor(Math.random()*2)) ? ydir='--': ydir='++'; } id2 = setTimeout('randomdir()', 20000); } function animate() { eval('x'+xdir); eval('y'+ydir); if (isNS) { pic1.moveTo((x+pageXOffset),(y+pageYOffset)) } else { pic1.pixelLeft = x+document.body.scrollLeft; pic1.pixelTop = y+document.body.scrollTop; } if (isNS) { if (pic1.top <= 5+pageYOffset) ydir = '++'; if (pic1.top >= wheight+pageYOffset) ydir = '--'; if (pic1.left >= wwidth+pageXOffset) xdir = '--'; if (pic1.left <= 5+pageXOffset) xdir = '++'; } else { if (pic1.pixelTop <= 5+document.body.scrollTop) ydir = '++'; if (pic1.pixelTop >= wheight+document.body.scrollTop) ydir = '--'; if (pic1.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--'; if (pic1.pixelLeft <= 5+document.body.scrollLeft) xdir = '++'; } id1 = setTimeout('animate()', 30); } // End --> </script> </HEAD> <!-- STEP TWO: Insert the event handlers into your BODY tag --> <BODY OnLoad="getwindowsize()" OnResize="getwindowsize()" background="space.jpg"> <!-- STEP THREE: Copy this code into the BODY of your HTML document --> <div id="pic1" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1"> <img src="alien.gif" border="0"> </div> <script language="javascript"> var pic1=eval('document.'+_all+'pic1'+_style); </script>
Скрипт астронавта
<! > <! > <!-- Begin astropic = "astronaut.jpg"; // location of YOUR astronaut image var xval = new Array(); // holds star coordinates var yval = new Array(); no = 100; // number of stars in the background speed = 200; // speed xp = 20 + 100 * Math.random(); yp = 20 + 100 * Math.random(); angle = 3.14 * Math.random(); // astronaut angle xinc = 3 * Math.sin(angle); yinc = 3; ie = (document.all)? 1 : 0; ns = (document.layers)? 1: 0; if (ie) { width = document.body.clientWidth; height = document.body.clientHeight; for (var i = 0; i <= no; i++) { document.write("<div id=\"div" + i+ "\" style=\"color:white;"); document.write("position:absolute;left:100;\">.</div>"); } document.write("<div id=\"diva\" style=\"position:absolute;\">"); document.write("<img src=" + astropic + " border=\"0\" width=\"65\" height=\"95\"></div>"); for (i = 0; i <= no; i++) { xval[i] = width * Math.random(); yval[i] = height * Math.random(); document.all["div" + i].style.left = xval[i]; document.all["div" + i].style.top = yval[i]; } } if (ns) { width = self.innerWidth; height = self.innerHeight; for (var i = 0; i <= no; i++) { document.write("<layer id=\"div" + i+ "\" style=\"color:white;"); document.write("position:absolute;left:100;\">.</layer>"); } document.write("<layer id=\"diva\" style=\"position:absolute;\">"); document.write("<img src=" + astropic + " border=\"0\" width=\"65\" height=\"95\"></layer>"); for (i = 0; i <= no; i++) { xval[i] = width * Math.random(); yval[i] = height * Math.random(); document.layers["div" + i].left = xval[i]; document.layers["div" + i].top = yval[i]; } } function star() { for (i = 0; i <= no; i = i+4) { xval[i] +=5; if ((i%20) == 0) xval[i] += 10; if(xval[i] >= width) xval[i] = width * Math.random(); if (ie) document.all["div" + i].style.left = xval[i]; if (ns) document.layers["div" + i].left = xval[i]; } return true; } function goangle() { angle = 3.14 * Math.random(); xinc = 3 * Math.sin(angle); return true; } function space() { if (ie) { document.all["diva"].style.left = xp; document.all["diva"].style.top = yp; } if (ns) { document.layers["diva"].left = xp; document.layers["diva"].top = yp; } xp += xinc; yp +=yinc; star(); if ((xp >= (width - 50)) || (xp <= 10)) { goangle(); xinc = (-1) * xinc; } if ((yp >= (height - 50)) || (yp <= 10)) { goangle(); yinc = (-1) * yinc; } setTimeout('space()', speed); } // End --> </script>
Эффект полёта форума в космосе
<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Joe Lard (darg36@home.com) --> <!-- Web Site: http://members.home.net/darg36 --> <! > <! > <!-- Begin ie4 = document.all?1:0; ns4 = document.layers?1:0; ns5 = (document.getElementById && !document.all)?1:0; time0ID = 0; time1ID = 0; time2ID = 0; wind = 0; w1 = w2 = -10; v1 = v2 = -10; x1 = x2 = -10; y1 = y2 = -10; xan = yan = -.25; // emulate snow or stars? (true | false) snow = false; // sinewave controlled star = true; // mouse controlled path function wave(){ // for snow xan = Math.sin(wind/57.3); wind+=Math.random()*5; if (wind>360) wind = 0; // yan = .25 // for water } // for stars function mm(e) { if (ns5) { xan = ((e.clientX)-csw)/csw; yan = ((e.clientY)-csh)/csh; } else { xan = (((ns4)?e.pageX:event.x)-csw)/csw; yan = (((ns4)?e.pageY:event.y)-csh)/csh; } } function init() { if (ns4) { z0 = document.zen.document.z0; z1 = document.zen.document.z1; } if (ns5) if (document.getElementsByTagName("*")) { document.all = document.getElementsByTagName("*") } if (star) { if (ns4 || ns5) { window.captureEvents(Event.MOUSEMOVE); window.onmousemove = mm; } document.onmousemove = mm; } fs=(ns4)? "":"; font-size:25px"; ret=""; tem=(ns4)? "<font size=5>":""; for (t=1;t<sh/28;t++) { for (u=1;u<sw/6;u++) tem += (Math.random()>.99)? ((Math.random()>.9)? "<font size="+((Math.random()*50)+12)+"px>.</font size>":"."):" "; tem += "<BR>"; } tem += (ns4)? "</font size>":""; ret += "<div style='position:absolute; left:0px; top:0px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:"+(sw)+"px; top:0px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:0px; top:"+(sh)+"px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:"+(sw)+"px; top:"+(sh)+"px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; if (ns4) { z0.document.write(ret); z0.document.close(); } if (ie4) z0.innerHTML = ret; if (ns5) document.all.z0.innerHTML = ret; ret=""; tem=(ns4)? "<font size=5>":""; for (t = 1; t < sh / 28; t++) { for (u = 1; u < sw / 6; u++) tem += (Math.random()>.99)? ((Math.random()>.9)? "<font size="+((Math.random()*50)+12)+"px>.</font size>":"."):" "; tem+="<BR>"; } tem += (ns4)? "</font size>":""; ret += "<div style='position:absolute; left:0px; top:0px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:"+(sw)+"px; top:0px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:0px; top:"+(sh)+"px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; ret += "<div style='position:absolute; left:"+(sw)+"px; top:"+(sh)+"px; width:"+sw+"px; height:"+sh+"px; color:white"+fs+"; font-family:Times'>"+tem+"</DIV>"; if (ns4) { z1.document.write(ret); z1.document.close(); } if (ie4) z1.innerHTML = ret; if (ns5) { document.all.z1.innerHTML = ret; z0 = document.all.z0; z1 = document.all.z1; } time1ID = setInterval('z1m()',33); time0ID = setInterval('z0m()',55); if (snow) time2ID=setInterval('wave()',77); } function halt() { if (time1ID) clearInterval(time1ID); if (time0ID) clearInterval(time0ID); if (time2ID) clearInterval(time2ID); } function z0m() { x1 -= 4 * xan; x2 -= 4 * yan; a = Math.round(x1); b = Math.round(x2); if (w1 != a) { w1 = a; if (w1 > 0) x1 = w1 = -sw; if (w1 < -sw) x1 = w1 = 0; if (!ns4) z0.style.left = w1 + "px"; } if (w2 != b) { w2 = b; if (w2 > 0) x2 = w2 = -sh; if (w2 < -sh) x2 = w2 = 0; if (!ns4) z0.style.top = w2 + "px"; } if (ns4) z0.moveTo(w1,w2); } function z1m() { y1 -= xan; y2 -= yan; a1 = Math.round(y1); b1 = Math.round(y2); if (v1 != a1) { v1 = a1; if (v1 > 0) y1 = v1 = -sw; if (v1 < -sw) y1 = v1 = 0; if (!ns4) z1.style.left = v1 + "px"; } if (v2 != b1) { v2 = b1; if (v2 > 0) y2 = v2 = -sh; if (v2 < -sh) y2 = v2 = 0; if (!ns4) z1.style.top = v2 + "px"; } if (ns4) z1.moveTo(v1,v2); } // End --> </script> </HEAD> <!-- STEP TWO: Insert the onLoad event handler into your BODY tag --> <BODY onLoad="init()" onunload="halt()"> <!-- STEP THREE: Copy this code into the BODY of your HTML document --> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin var sw = (ie4)? document.body.offsetWidth:window.innerWidth; var sh = (ie4)? document.body.offsetHeight:window.innerHeight; //sw=200; sh=200; field width and height var csw = Math.round(sw/2); var csh = Math.round(sh/2); ret="<STYLE TYPE='text/css'><!--\n"; ret+="#zen {position:absolute; left:0; top:0; width:"+sw+"; height:"+sh+ "; font-size:3000px; font-family:Times; clip:rect(0,"+(sw)+","+(sh)+ ",0); overflow:hidden; z-Index:0}"; ret+="#z0 {position:absolute; left:-10; top:-10; width:"+(sw*2)+ "; height:"+(sh*2)+"; clip:rect(0,"+(sw*2)+","+(sh*2)+",0)}"; ret+="#z1 {position:absolute; left:-10; top:-10; width:"+(sw*2)+ "; height:"+(sh*2)+"; clip:rect(0,"+(sw*2)+","+(sh*2)+",0)}"; ret+="#ar {position:absolute; left:10; top:10; width:100; height:100;"+ " z-Index:1000; color:red}"; ret+="//-->\n</STYLE>"; if (ns4) ret+="<DIV id=zen>_"; else ret+="<DIV id=zen>"; ret+="<DIV id=z1></DIV>"; ret+="<DIV id=z0></DIV>"; ret+="</DIV>"; document.write(ret); // End --> </script> <DIV id=ar><a href="javascript:halt()"> </A></DIV>
Скрипт фейерверков на заднем плане
<layer name="a0" left=10 top=10 visibility=show bgcolor="#ffffff" clip="0,0,1,1"></layer> <layer name="a1" left=10 top=10 visibility=show bgcolor="#fff000" clip="0,0,1,1"></layer> <layer name="a2" left=10 top=10 visibility=show bgcolor="#ffa000" clip="0,0,1,1"></layer> <layer name="a3" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer> <layer name="a4" left=10 top=10 visibility=show bgcolor="#00ff00" clip="0,0,1,1"></layer> <layer name="a5" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer> <layer name="a6" left=10 top=10 visibility=show bgcolor="#ff0000" clip="0,0,1,1"></layer> <layer name="a7" left=10 top=10 visibility=show bgcolor="#ffffff" clip="0,0,1,1"></layer> <layer name="a8" left=10 top=10 visibility=show bgcolor="#fff000" clip="0,0,1,1"></layer> <layer name="a9" left=10 top=10 visibility=show bgcolor="#ffa000" clip="0,0,1,1"></layer> <layer name="a10" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer> <layer name="a11" left=10 top=10 visibility=show bgcolor="#00ff00" clip="0,0,2,2"></layer> <layer name="a12" left=10 top=10 visibility=show bgcolor="#0000ff" clip="0,0,2,2"></layer> <layer name="a13" left=10 top=10 visibility=show bgcolor="#ff0000" clip="0,0,2,2"></layer> <div id="starsDiv" style="position:absolute;top:0px;left:0px"> <div style="position:relative;width:2px;height:2px;background:#ffffff;font-size:2px"></div> <div style="position:relative;width:1px;height:1px;background:#fff000;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#ffa000;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#ff00ff;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#00ff00;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#0000ff;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#FF0000;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#ffffff;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#fff000;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#ffa000;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#ff00ff;font-size:1px"></div> <div style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px"></div> <div style="position:relative;width:1px;height:1px;background:#0000ff;font-size:1px"></div> <div style="position:relative;width:1px;height:1px;background:#FF0000;font-size:1px"></div> </div> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Kurt Grigg (kurt.grigg@virgin.net) --> <!-- Web Site: http://freespace.virgin.net/kurt.grigg --> <!-- Begin var Clrs = new Array(9); Clrs[0] = 'ff0000'; Clrs[1] = '00ff00'; Clrs[2] = '000aff'; Clrs[3] = 'ff00ff'; Clrs[4] = 'ffa500'; Clrs[5] = 'ffff00'; Clrs[6] = '00ff00'; Clrs[7] = 'ffffff'; Clrs[8] = 'fffff0'; var sClrs = new Array(5); sClrs[0] = 'ffa500'; sClrs[1] = '55ff66'; sClrs[2] = 'AC9DFC'; sClrs[3] = 'fff000'; sClrs[4] = 'fffff0'; var yBase; var xBase; var step; var currStep = 0; var Xpos = 1; var Ypos = 1; var initialStarColor = 'ffa000'; var Mtop = 250; var Mleft = 250; function Fireworks() { if (document.all) { yBase = window.document.body.offsetHeight / 3; xBase = window.document.body.offsetWidth / 8; } else if (document.layers) { yBase = window.innerHeight / 3; xBase = window.innerWidth / 8; } if (document.all) { step = 5; for ( i = 0 ; i < starsDiv.all.length ; i++ ) { for (ai = 0; ai < Clrs.length; ai++) { var c = Math.round(Math.random()*[ai]); } if (currStep < 90) starsDiv.all[i].style.background=initialStarColor; if (currStep > 90) starsDiv.all[i].style.background=Clrs[c]; starsDiv.all[i].style.top = Mtop + yBase*Math.sin((currStep+i*5)/3)*Math.sin(550+currStep/100) starsDiv.all[i].style.left = Mleft + yBase*Math.cos((currStep+i*5)/3)*Math.sin(550+currStep/100) } } else if (document.layers) { step = 5; for ( j = 0 ; j < 14 ; j++ ) { //number of NS layers! var templayer = "a"+j; for (ai = 0; ai < Clrs.length; ai++) { var c = Math.round(Math.random()*[ai]); } if (currStep < 90) document.layers[templayer].bgColor=initialStarColor; if (currStep > 90) document.layers[templayer].bgColor=Clrs[c]; document.layers[templayer].top = Mtop + yBase*Math.sin((currStep+j*5)/3)*Math.sin(550+currStep/100) document.layers[templayer].left = Mleft + yBase*Math.cos((currStep+j*5)/3)*Math.sin(550+currStep/100) } } currStep+= step; T=setTimeout("Fireworks()",5); if (currStep == 220) { currStep = -10; for (n = 0; n < sClrs.length; n++) { var k = Math.round(Math.random()*n); } initialStarColor = sClrs[k]; if (document.all) { Dtop = window.document.body.clientHeight - 250; Dleft = xBase * 3.5; Mtop = Math.round(Math.random()*Dtop); Mleft = Math.round(Math.random()*Dleft); document.all.starsDiv.style.top = Mtop+document.body.scrollTop; document.all.starsDiv.style.left = Mleft+document.body.scrollLeft; } else if (document.layers) { Dleft = window.innerWidth - 100; Dtop = window.innerHeight - 100; Mtop = Math.round(Math.random()*Dtop+window.pageYOffset); Mleft = Math.round(Math.random()*Dleft+window.pageXOffset); document.layers[templayer].top = Mtop; document.layers[templayer].left = Mleft; } if ((Mtop < 20) || (Mleft < 20)) { Mtop += 90; Mleft += 90; } } } Fireworks(); // End --> </script>
Позже выложу ещё.Если что не работает-пишите.Помогу.Вставлять в HТML-верх.Может не работать в Мозиле.В эксплоррере работает точно,в опере не проверял.
Отредактировано sasha_nm (2010-05-04 21:00:01)