查看完整版本: 魚兒水中游

gasver2 8-12-2009 10:14

魚兒水中游

&lt;script language="JavaScript"&gt; <BR>&lt;!--<BR>&lt;!--在此修改圖案出現在畫面上的數量--&gt;<BR>var no = 10; <BR>&lt;!--在此修改圖案游動的速度,數值越大越慢,越小越快--&gt;<BR>var speed = 10; <BR>snow = new Array(); <BR>&lt;!--在此修改需使用的圖案連結路徑--&gt;<BR>snow[0] = "圖檔連結路徑";<BR>snow[1] = "圖檔連結路徑";<BR>snow[2] = "圖檔連結路徑";<BR>snow[3] = "圖檔連結路徑";<BR>snow[4] = "圖檔連結路徑";<BR><BR>var maxsize = 100;&nbsp; <BR>var ns4up = (document.layers) ? 1 : 0;&nbsp; <BR>var ie4up = (document.all) ? 1 : 0; <BR>var dx, xp, yp;&nbsp;&nbsp;&nbsp; <BR>var am, stx, sty;&nbsp; <BR>var i, doc_width = 800, doc_height = 600; <BR>if (ns4up) { <BR>&nbsp;doc_width = self.innerWidth; <BR>&nbsp;doc_height = self.innerHeight; <BR>} else if (ie4up) { <BR>&nbsp;doc_width = document.body.clientWidth; <BR>&nbsp;doc_height = document.body.clientHeight; <BR>} <BR>dx = new Array(); <BR>xp = new Array(); <BR>yp = new Array(); <BR>am = new Array(); <BR>stx = new Array(); <BR>sty = new Array(); <BR>var j = 0; <BR>for (i = 0; i &lt; no; ++ i) { <BR>&nbsp;dx[i] = 0;<BR>&nbsp;xp[i] = Math.random()*(doc_height-maxsize);&nbsp; <BR>&nbsp;yp[i] = Math.random()*(doc_width-maxsize); <BR>&nbsp;am[i] = Math.random()*10;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;stx[i] = 0.02 + Math.random()/10; <BR>&nbsp;sty[i] = 0.7 + Math.random();&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;if (ns4up) {<BR>&nbsp;&nbsp;if (i == 0) { <BR>&nbsp;&nbsp;&nbsp;document.write("&lt;layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"&gt;&lt;img src=\"" + snow[j] + "\" border=\"0\"&gt;&lt;/layer&gt;"); <BR>&nbsp;&nbsp;} else { <BR>&nbsp;&nbsp;&nbsp;document.write("&lt;layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"&gt;&lt;img src=\"" + snow[j] + "\" border=\"0\"&gt;&lt;/layer&gt;"); <BR>&nbsp;&nbsp;} <BR>&nbsp;} else if (ie4up) { <BR>&nbsp;&nbsp;if (i == 0) { <BR>&nbsp;&nbsp;&nbsp;document.write("&lt;div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"&gt;&lt;img src=\"" + snow[j] + "\" border=\"0\"&gt;&lt;/div&gt;"); <BR>&nbsp;&nbsp;} else { <BR>&nbsp;&nbsp;&nbsp;document.write("&lt;div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"&gt;&lt;img src=\"" + snow[j] + "\" border=\"0\"&gt;&lt;/div&gt;"); <BR>&nbsp;&nbsp;} &nbsp;} <BR>&nbsp;if (j == (snow.length-1)) { j = 0; } else { j += 1; } <BR>}&nbsp; <BR>document.write("&lt;div id=\"damy\" style=\"POSITION: absolute; width:1; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: " + (doc_width+maxsize) + "px;\"&gt; &lt;/div&gt;"); <BR>function snowNS() {&nbsp; // Netscape main animation function <BR>&nbsp;for (i = 0; i &lt; no; ++ i) {&nbsp; // iterate for every dot <BR>&nbsp;&nbsp;if (i%2) { <BR>&nbsp;&nbsp;&nbsp;yp[i] += sty[i]; <BR>&nbsp;&nbsp;&nbsp;if (yp[i] &gt; doc_width) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;xp[i] = Math.random()*(doc_height-am[i]-maxsize); <BR>&nbsp;&nbsp;&nbsp;&nbsp;yp[i] = 0-maxsize; <BR>&nbsp;&nbsp;&nbsp;&nbsp;stx[i] = 0.02 + Math.random()/10; <BR>&nbsp;&nbsp;&nbsp;&nbsp;sty[i] = 0.7 + Math.random(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_width = self.innerWidth; <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_height = self.innerHeight; <BR>&nbsp;&nbsp;&nbsp;} <BR>&nbsp;&nbsp;} else { <BR>&nbsp;&nbsp;&nbsp;yp[i] -= sty[i]; <BR>&nbsp;&nbsp;&nbsp;if (yp[i] &lt; -maxsize) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;xp[i] = Math.random()*(doc_height-am[i]-maxsize); <BR>&nbsp;&nbsp;&nbsp;&nbsp;yp[i] = doc_width; <BR>&nbsp;&nbsp;&nbsp;&nbsp;stx[i] = 0.02 + Math.random()/10; <BR>&nbsp;&nbsp;&nbsp;&nbsp;sty[i] = 0.7 + Math.random(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_width = self.innerWidth; <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_height = self.innerHeight; <BR>&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;} <BR>&nbsp;&nbsp;dx[i] += stx[i]; <BR>&nbsp;&nbsp;document.layers["dot"+i].top = xp[i] + am[i]*Math.sin(dx[i]); <BR>&nbsp;&nbsp;document.layers["dot"+i].left = yp[i]; <BR>&nbsp;} <BR>&nbsp;setTimeout("snowNS()", speed); <BR>}&nbsp; <BR>function snowIE() {&nbsp; // IE main animation function <BR>&nbsp;for (i = 0; i &lt; no; ++ i) {&nbsp; // iterate for every dot <BR>&nbsp;&nbsp;if (i%2) { <BR>&nbsp;&nbsp;&nbsp;yp[i] += sty[i]; <BR>&nbsp;&nbsp;&nbsp;if (yp[i] &gt; doc_width) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;xp[i] = Math.random()*(doc_height-am[i]-maxsize); <BR>&nbsp;&nbsp;&nbsp;&nbsp;yp[i] = 0-maxsize; <BR>&nbsp;&nbsp;&nbsp;&nbsp;stx[i] = 0.02 + Math.random()/10; <BR>&nbsp;&nbsp;&nbsp;&nbsp;sty[i] = 0.7 + Math.random(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_width = document.body.clientWidth; <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_height = document.body.clientHeight; <BR>&nbsp;&nbsp;&nbsp;} <BR>&nbsp;&nbsp;} else { <BR>&nbsp;&nbsp;&nbsp;yp[i] -= sty[i]; <BR>&nbsp;&nbsp;&nbsp;if (yp[i] &lt; -maxsize) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;xp[i] = Math.random()*(doc_height-am[i]-maxsize); <BR>&nbsp;&nbsp;&nbsp;&nbsp;yp[i] = doc_width; <BR>&nbsp;&nbsp;&nbsp;&nbsp;stx[i] = 0.02 + Math.random()/10; <BR>&nbsp;&nbsp;&nbsp;&nbsp;sty[i] = 0.7 + Math.random(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_width = document.body.clientWidth; <BR>&nbsp;&nbsp;&nbsp;&nbsp;doc_height = document.body.clientHeight; <BR>&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;} <BR>&nbsp;&nbsp;dx[i] += stx[i]; <BR>&nbsp;&nbsp;document.all["dot"+i].style.pixelTop = xp[i] + am[i]*Math.sin(dx[i]); <BR>&nbsp;&nbsp;document.all["dot"+i].style.pixelLeft = yp[i]; <BR>&nbsp;} <BR>&nbsp;setTimeout("snowIE()", speed); <BR>}&nbsp; <BR>if (ns4up) { <BR>&nbsp;snowNS(); <BR>} else if (ie4up) { <BR>&nbsp;snowIE(); <BR>}&nbsp; <BR>//--&gt; <BR>&nbsp;&lt;/script&gt; <BR>

8-12-2009 18:07

複製上列語法

<form name="copy">
<textarea cols="40" name="txt" rows="4" style="BACKGROUND-COLOR:#ffffff; COLOR:#000000; FONT-SIZE:9pt">
<script language="JavaScript">
<!--
<!--在此修改圖案出現在畫面上的數量-->
var no = 10;
<!--在此修改圖案游動的速度,數值越大越慢,越小越快-->
var speed = 10;
snow = new Array();
<!--在此修改需使用的圖案連結路徑-->
snow[0] = "http://www.bunbunhk.com/BBS/js/fish1.jpg";
snow[1] = "http://www.bunbunhk.com/BBS/js/fish2.jpg";
snow[2] = "http://www.bunbunhk.com/BBS/js/fish3.jpg";
snow[3] = "http://www.bunbunhk.com/BBS/js/fish4.jpg";
snow[4] = "http://www.bunbunhk.com/BBS/js/fish0.jpg";

var maxsize = 100;  
var ns4up = (document.layers) ? 1 : 0;  
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;   
var am, stx, sty;  
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
var j = 0;
for (i = 0; i < no; ++ i) {
dx[i] = 0;
xp[i] = Math.random()*(doc_height-maxsize);  
yp[i] = Math.random()*(doc_width-maxsize);
am[i] = Math.random()*10;         
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();     
if (ns4up) {
  if (i == 0) {
   document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snow[j] + "\" border=\"0\"></layer>");
  } else {
   document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snow[j] + "\" border=\"0\"></layer>");
  }
} else if (ie4up) {
  if (i == 0) {
   document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>");
  } else {
   document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>");
  }  }
if (j == (snow.length-1)) { j = 0; } else { j += 1; }
}  
document.write("<div id=\"damy\" style=\"POSITION: absolute; width:1; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: " + (doc_width+maxsize) + "px;\"> </div>");
function snowNS() {  // Netscape main animation function
for (i = 0; i < no; ++ i) {  // iterate for every dot
  if (i%2) {
   yp[i] += sty[i];
   if (yp[i] > doc_width) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = 0-maxsize;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
   }
  } else {
   yp[i] -= sty[i];
   if (yp[i] < -maxsize) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = doc_width;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
   }   }
  dx[i] += stx[i];
  document.layers["dot"+i].top = xp[i] + am[i]*Math.sin(dx[i]);
  document.layers["dot"+i].left = yp[i];
}
setTimeout("snowNS()", speed);
}  
function snowIE() {  // IE main animation function
for (i = 0; i < no; ++ i) {  // iterate for every dot
  if (i%2) {
   yp[i] += sty[i];
   if (yp[i] > doc_width) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = 0-maxsize;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;
   }
  } else {
   yp[i] -= sty[i];
   if (yp[i] < -maxsize) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = doc_width;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;
   }   }
  dx[i] += stx[i];
  document.all["dot"+i].style.pixelTop = xp[i] + am[i]*Math.sin(dx[i]);
  document.all["dot"+i].style.pixelLeft = yp[i];
}
setTimeout("snowIE()", speed);
}  
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}  
//-->
</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>


<script language="JavaScript">
<!--
<!--在此修改圖案出現在畫面上的數量-->
var no = 10;
<!--在此修改圖案游動的速度,數值越大越慢,越小越快-->
var speed = 10;
snow = new Array();
<!--在此修改需使用的圖案連結路徑-->
snow[0] = "http://www.bunbunhk.com/BBS/js/fish1.jpg";
snow[1] = "http://www.bunbunhk.com/BBS/js/fish2.jpg";
snow[2] = "http://www.bunbunhk.com/BBS/js/fish3.jpg";
snow[3] = "http://www.bunbunhk.com/BBS/js/fish4.jpg";
snow[4] = "http://www.bunbunhk.com/BBS/js/fish0.jpg";

var maxsize = 100;  
var ns4up = (document.layers) ? 1 : 0;  
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;   
var am, stx, sty;  
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
var j = 0;
for (i = 0; i < no; ++ i) {
dx[i] = 0;
xp[i] = Math.random()*(doc_height-maxsize);  
yp[i] = Math.random()*(doc_width-maxsize);
am[i] = Math.random()*10;         
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();     
if (ns4up) {
  if (i == 0) {
   document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snow[j] + "\" border=\"0\"></layer>");
  } else {
   document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snow[j] + "\" border=\"0\"></layer>");
  }
} else if (ie4up) {
  if (i == 0) {
   document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>");
  } else {
   document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>");
  }  }
if (j == (snow.length-1)) { j = 0; } else { j += 1; }
}  
document.write("<div id=\"damy\" style=\"POSITION: absolute; width:1; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: " + (doc_width+maxsize) + "px;\"> </div>");
function snowNS() {  // Netscape main animation function
for (i = 0; i < no; ++ i) {  // iterate for every dot
  if (i%2) {
   yp[i] += sty[i];
   if (yp[i] > doc_width) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = 0-maxsize;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
   }
  } else {
   yp[i] -= sty[i];
   if (yp[i] < -maxsize) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = doc_width;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
   }   }
  dx[i] += stx[i];
  document.layers["dot"+i].top = xp[i] + am[i]*Math.sin(dx[i]);
  document.layers["dot"+i].left = yp[i];
}
setTimeout("snowNS()", speed);
}  
function snowIE() {  // IE main animation function
for (i = 0; i < no; ++ i) {  // iterate for every dot
  if (i%2) {
   yp[i] += sty[i];
   if (yp[i] > doc_width) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = 0-maxsize;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;
   }
  } else {
   yp[i] -= sty[i];
   if (yp[i] < -maxsize) {
    xp[i] = Math.random()*(doc_height-am[i]-maxsize);
    yp[i] = doc_width;
    stx[i] = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;
   }   }
  dx[i] += stx[i];
  document.all["dot"+i].style.pixelTop = xp[i] + am[i]*Math.sin(dx[i]);
  document.all["dot"+i].style.pixelLeft = yp[i];
}
setTimeout("snowIE()", speed);
}  
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}  
//-->
</script>
頁: [1]
查看完整版本: 魚兒水中游