我想要下雪既Jave.... at Html.. 有冇人識寫?(20)

2006-11-25 6:13 pm
我想要下雪同下樹葉既Java 語法...
有冇人識?

即係用Html寫既Java,
另外有冇地方下載下雪同一D特別既Effects?

回答 (1)

2006-11-25 7:01 pm
✔ 最佳答案
以下係落雪既Java Script

放係<head>與</head>之間

<style type="text/css& quot;>
.snow {position:absolute; layer-background-col or:lightblue; visibility:visible; top:-50px; width:50px; height:50px; font-size:1px; background-color:lig htblue}
</style>

放係<body>與</body>之間

<SCRIPT Language="JavaS cript">
var drops=75; //NUMBER OF OBJECTS YOU WANT.
var level=1; //SPEED LEVEL 1 to 5. 1=SLOWER, 5=FASTER
var isNS=(document.layer s);
var _all= (isNS)? '' : 'all.' ;
var _style= (isNS) ? '' : '.style' ;
var w_x, w_y, id=0;
for(i=1;i<=drops; i++){
document.writeln( 9;<div id="drop'+i +'" class="snow&quo t;></div>&# 39;);
eval('var drop'+i+'=do cument.'+_all+&# 39;drop'+i+_styl e);
}
function init(){
level=Math.max(Math. min(5,level),1)
findwindowparams();
for(i=1;i<=drops; i++){
getstartpos(eval( 9;drop'+i));
(isNS)? eval('drop'+ i+'.top='+Ma th.floor(Math.random ()*(w_y-10))) : eval('drop'+ i+'.top='+Ma th.floor(Math.random ()*(w_y-10))) ;
}
setInterval('mov edrop()',50);
}
function getstartpos(obj){
obj.size=Math.floor( Math.random()*5)+1
obj.ystep=obj.size*l evel;
obj.xstep=obj.ystep/ 5;
if(isNS){
obj.clip.width=obj.c lip.height=obj.size;
obj.left=obj.xpos=Ma th.floor(Math.random ()*w_x)-obj.size;
obj.top=0;
}else{
obj.width=obj.height =obj.size;
obj.pixelTop=0;
obj.pixelLeft=obj.xp os=Math.floor(Math.r andom()*w_x)-obj.siz e;
}}
function movedrop(dropN){
for(i=1;i<=drops; i++){
dropN=eval('drop '+i);
dropN.xpos-=dropN.xs tep;
if(isNS){
if( (dropN.top+dropN.yst ep+dropN.size>=w_ y+pageYOffset) || (dropN.xpos-dropN.si ze<pageXOffset)){
getstartpos(dropN);
}else{
dropN.top+=dropN.yst ep;
dropN.left=dropN.xpo s;
}}else{
if( (dropN.pixelTop+drop N.ystep+dropN.size&g t;=w_y+document.body .scrollTop) || (dropN.xpos-dropN.si ze<document.body. scrollLeft) || (dropN.pixelLeft> w_x-dropN.size)){
getstartpos(dropN);
}else{
dropN.pixelTop+=drop N.ystep;
dropN.pixelLeft=drop N.xpos;
}}}}
function findwindowparams(){
w_x=(isNS)? window.innerWidth : document.body.client Width;
w_y=(isNS)? window.innerHeight : document.body.client Height;
}
function reloadNS(){
setTimeout('wind ow.location.reload() ', 500);
}
(isNS)? window.onresize=relo adNS : window.onresize=find windowparams;
window.onload=init;
</SCRIPT>

PS. 可以將以下橙色既地方改為自己鐘意既~
.snow {position:absolute; layer-background-col or:lightblue; visibility:visible; top:-50px; width:50px; height:50px; font-size:1px; background-color:lightblue}
var drops=75; //NUMBER OF OBJECTS YOU WANT.
var level=1; //SPEED LEVEL 1 to 5. 1=SLOWER, 5=FASTER


收錄日期: 2021-04-12 22:33:41
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061125000051KK01018

檢視 Wayback Machine 備份