查看完整版本: 流星雨背景效果

25-1-2010 18:07

流星雨背景效果

<P>可將語法貼往語法測試板試看效果</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&lt;script language="JavaScript"&gt;<BR>&lt;!--<BR>if (document.all){<BR>xL=5; <BR>xH=0;<BR>xW=0;<BR>xR=0;<BR>xE=0;<BR>xMY=0;<BR>xMX=0;<BR>xWd=0;<BR>xHd=0;<BR>xF=new Array();<BR>xY=new Array();<BR>xX=new Array();<BR>xS=new Array();<BR>xA=new Array();<BR>xB=new Array();<BR>ini=new Array();<BR>cl=new Array('#fff000','#0000FF','#ff0000','#00ff00','#ff00ff','#ffa500')<BR>document.write('&lt;div id="xouter" style="position:absolute;top:0px;left:0px"&gt;&lt;div style="position:relative"&gt;');<BR>for (i=0; i &lt; xL; i++){<BR>document.write('&lt;div id="xie" style="position:absolute;top:0;left:0;width:10px;height:10px;'+'font-family:Courier New;font-size:50px;color:white"&gt;.&lt;/div&gt;');<BR>}<BR>document.write('&lt;/div&gt;&lt;/div&gt;');<BR>//Initial Placement!<BR>function Set(){<BR>for (i=0; i &lt; xL; i++){<BR>xH=window.document.body.offsetHeight;<BR>xW=window.document.body.offsetWidth;<BR>xA[i]=Math.round(Math.random()*xH);<BR>xB[i]=Math.round(Math.random()*xW);<BR>xS[i]=Math.random()*0.07+0.05;<BR>xR=Math.round(Math.random()*3);<BR>xE=Math.round(Math.random()*2500+50)<BR>if (xR == 3) xB[i]=-xE;<BR>if (xR == 2) xB[i]=xW+xE;<BR>if (xR == 1) xA[i]=-xE;<BR>if (xR == 0) xA[i]=xH;<BR>xF[i]=xW/14;<BR>}}<BR>Set();<BR>function Assign(){<BR>xouter.style.top=document.body.scrollTop;<BR>for (i=0; i &lt; xL; i++){<BR>xF[i]-=xS[i]*25;<BR>if (xF[i] &lt; 4) xF[i]=3;<BR>xie[i].style.top =xY[i];<BR>xie[i].style.left=xX[i];<BR>xie[i].style.fontSize=xF[i];<BR>xie[i].style.filter='glow(color='+ini[i]+', strength='+xF[i]/3+')';<BR>}}<BR>function fly(){<BR>var N=Math.floor(Math.random()*cl.length)<BR>xMY=window.document.body.clientHeight/2;<BR>xMX=window.document.body.clientWidth/2;<BR>xWd=Math.round(Math.random()*40+5);<BR>xHd=Math.round(Math.random()*30+5);<BR>for (i=0; i &lt; xL; i++)<BR>{<BR>xY[i]=xA[i]+=(xMY-xA[i])*(xS[i]);&nbsp; <BR>xX[i]=xB[i]+=(xMX-xB[i])*(xS[i]);&nbsp; <BR>if ((xX[i] &gt; xMX-xWd) && (xX[i] &lt; xMX+xWd) && (xY[i] &gt; xMY-xHd) && (xY[i] &lt; xMY+xHd)){</P>
<P>&nbsp;xH=window.document.body.offsetHeight;<BR>&nbsp;xW=window.document.body.offsetWidth;<BR>&nbsp;xA[i]=Math.round(Math.random()*xH);<BR>&nbsp;xB[i]=Math.round(Math.random()*xW);<BR>&nbsp;xS[i]=Math.random()*0.05+0.05;<BR>&nbsp;xR=Math.round(Math.random()*3);<BR>&nbsp;xE=Math.round(Math.random()*50+50)<BR>&nbsp;if (xR == 3) xB[i]=-xE;<BR>&nbsp;if (xR == 2) xB[i]=xW+xE;<BR>&nbsp;if (xR == 1) xA[i]=-xE;<BR>&nbsp;if (xR == 0) xA[i]=xH+xE;<BR>}<BR>if ((xX[i] &lt; 0) || (xX[i] &gt; xW) || (xY[i] &lt; 0) || (xY[i] &gt; xH)) <BR>&nbsp;{<BR>&nbsp;xF[i]=xW/14;<BR>&nbsp;ini[i]=cl[N];<BR>&nbsp;}}<BR>Assign();<BR>setTimeout('fly()',10);<BR>}<BR>fly();<BR>}<BR>--&gt;<BR>&lt;/script&gt; </P>

25-5-2013 12:02

複製上列語法

<form name="copy">
<textarea cols="40" name="txt" rows="4" style="BACKGROUND-COLOR:#ffffff; COLOR:#000000; FONT-SIZE:9pt">
<script language="JavaScript">
<!--
if (document.all){
xL=5;
xH=0;
xW=0;
xR=0;
xE=0;
xMY=0;
xMX=0;
xWd=0;
xHd=0;
xF=new Array();
xY=new Array();
xX=new Array();
xS=new Array();
xA=new Array();
xB=new Array();
ini=new Array();
cl=new Array('#fff000','#0000FF','#ff0000','#00ff00','#ff00ff','#ffa500')
document.write('<div id="xouter" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < xL; i++){
document.write('<div id="xie" style="position:absolute;top:0;left:0;width:10px;height:10px;'+'font-family:Courier New;font-size:50px;color:white">.</div>');
}
document.write('</div></div>');
//Initial Placement!
function Set(){
for (i=0; i < xL; i++){
xH=window.document.body.offsetHeight;
xW=window.document.body.offsetWidth;
xA[i]=Math.round(Math.random()*xH);
xB[i]=Math.round(Math.random()*xW);
xS[i]=Math.random()*0.07+0.05;
xR=Math.round(Math.random()*3);
xE=Math.round(Math.random()*2500+50)
if (xR == 3) xB[i]=-xE;
if (xR == 2) xB[i]=xW+xE;
if (xR == 1) xA[i]=-xE;
if (xR == 0) xA[i]=xH;
xF[i]=xW/14;
}}
Set();
function Assign(){
xouter.style.top=document.body.scrollTop;
for (i=0; i < xL; i++){
xF[i]-=xS[i]*25;
if (xF[i] < 4) xF[i]=3;
xie[i].style.top =xY[i];
xie[i].style.left=xX[i];
xie[i].style.fontSize=xF[i];
xie[i].style.filter='glow(color='+ini[i]+', strength='+xF[i]/3+')';
}}
function fly(){
var N=Math.floor(Math.random()*cl.length)
xMY=window.document.body.clientHeight/2;
xMX=window.document.body.clientWidth/2;
xWd=Math.round(Math.random()*40+5);
xHd=Math.round(Math.random()*30+5);
for (i=0; i < xL; i++)
{
xY[i]=xA[i]+=(xMY-xA[i])*(xS[i]);  
xX[i]=xB[i]+=(xMX-xB[i])*(xS[i]);  
if ((xX[i] > xMX-xWd) && (xX[i] < xMX+xWd) && (xY[i] > xMY-xHd) && (xY[i] < xMY+xHd)){

xH=window.document.body.offsetHeight;
xW=window.document.body.offsetWidth;
xA[i]=Math.round(Math.random()*xH);
xB[i]=Math.round(Math.random()*xW);
xS[i]=Math.random()*0.05+0.05;
xR=Math.round(Math.random()*3);
xE=Math.round(Math.random()*50+50)
if (xR == 3) xB[i]=-xE;
if (xR == 2) xB[i]=xW+xE;
if (xR == 1) xA[i]=-xE;
if (xR == 0) xA[i]=xH+xE;
}
if ((xX[i] < 0) || (xX[i] > xW) || (xY[i] < 0) || (xY[i] > xH))
{
xF[i]=xW/14;
ini[i]=cl[N];
}}
Assign();
setTimeout('fly()',10);
}
fly();
}
-->
</script>
</textarea><br>
<input onclick="javascript:this.form.txt.focus();this.form.txt.select();" type="button" value="全選">
</form>

<BR>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-4078143172638881";
/* 336X280 */
google_ad_slot = "3268225205";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
頁: [1]
查看完整版本: 流星雨背景效果