09/10/2018, 18:13

làm sao tuyết rơi từ dưới lên????

Mấy huynh cho đệ hỏi có Code nào làm hình "rơi" trên màn hình không ???
Rơi lên hay xuống gì cũng được
ga__Rung viết 20:20 ngày 09/10/2018
<body bgcolor=black oncontextmenu="return false" scroll=no leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload=fly()>


<script language="javascript1.2">

function disableselect(e){
return false
}
function reEnable(){
return true
}

//if IE4
document.onselectstart=new Function ("return false")

//if NS6
if (window.sidebar){
document.onmousedown=disableselect;
document.onclick=reEnable;
}
</script>
<SCRIPT language=JavaScript>
SmallStars = 30;
LargeStars = 20;
SmallYpos = new Array();
SmallXpos = new Array();
LargeYpos = new Array();
LargeXpos = new Array();
Smallspeed= new Array();
Largespeed= new Array();
ns=(document.layers)?1:0;
if (ns){
for (i = 0; i < SmallStars; i++)
{document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>")}
for (i = 0; i < LargeStars; i++)
{document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>")}
}
else{
document.write('<div style="position:absolute;top:0px;left:0px">');
document.write('<div style="position:relative">');
for (i = 0; i < SmallStars; i++)
{document.write('<div id="si" style="position:absolute;top:0;left:0;width:1px;he ight:1px;background:#fffff0;font-size:1px"></div>')}
document.write('</div>');
document.write('</div>');
document.write('<div style="position:absolute;top:0px;left:0px">');
document.write('<div style="position:relative">');
for (i = 0; i < LargeStars; i++)
{document.write('<div id="li" style="position:absolute;top:0;left:0;width:2px;he ight:2px;background:#ffffff;font-size:2px"></div>')}
document.write('</div>');
document.write('</div>');
}
WinHeight=(document.layers)?window.innerHeight:win dow.document.body.clientHeight;
WinWidth=(document.layers)?window.innerWidth:windo w.document.body.clientWidth;
//Inital placement!
for (i=0; i < SmallStars; i++)
{
SmallYpos[i] = Math.round(Math.random()*WinHeight);
SmallXpos[i] = Math.round(Math.random()*WinWidth);
Smallspeed[i]= Math.random()*5+1;
}
for (i=0; i < LargeStars; i++)
{
LargeYpos[i] = Math.round(Math.random()*WinHeight);
LargeXpos[i] = Math.round(Math.random()*WinWidth);
Largespeed[i]= Math.random()*10+5;
}
function fly(){
var WinHeight=(document.layers)?window.innerHeight:win dow.document.body.clientHeight;
var WinWidth=(document.layers)?window.innerWidth:windo w.document.body.clientWidth;
var hscrll=(document.layers)?window.pageYOffset:docume nt.body.scrollTop;
var wscrll=(document.layers)?window.pageXOffset:docume nt.body.scrollLeft;

for (i=0; i < LargeStars; i++)
{
LargeXpos[i]-=Largespeed[i];
if (LargeXpos[i] < -10)
{
LargeXpos[i]=WinWidth;
LargeYpos[i]=Math.round(Math.random()*WinHeight);
Largespeed[i]=Math.random()*10+5;
}
if (ns){
document.layers['ln'+i].left=LargeXpos[i];
document.layers['ln'+i].top=LargeYpos[i]+hscrll;
}
else{
li[i].style.pixelLeft=LargeXpos[i];
li[i].style.pixelTop=LargeYpos[i]+hscrll;
}
}

for (i=0; i < SmallStars; i++)
{
SmallXpos[i]-=Smallspeed[i];
if (SmallXpos[i] < -10)
{
SmallXpos[i]=WinWidth;
SmallYpos[i]=Math.round(Math.random()*WinHeight);
Smallspeed[i]=Math.random()*5+1;
}
if (ns){
document.layers['sn'+i].left=SmallXpos[i];
document.layers['sn'+i].top=SmallYpos[i]+hscrll;
}
else{
si[i].style.pixelLeft=SmallXpos[i];
si[i].style.pixelTop=SmallYpos[i]+hscrll;
}
}
setTimeout('fly()',1);
}
</SCRIPT>
</br>
</br>
</br></br></br>

<object classid="clsid27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="780" height="212">
<param name="movie" value="../flash/designer1.swf" tppabs="../flash/designer1.swf">
<param name="quality" value="Low">
<embed src="flash/0429intro.swf" tppabs="http://namvanet.homeip.net/flash/0429intro.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="780" height="212" quality="Low"></object>
duclee viết 20:18 ngày 09/10/2018
ủa, đang hỏi trong C hay HTML?
cfmanager viết 20:16 ngày 09/10/2018
Cái này là đúng theo yêu cầu của bạn đó! Từ trước tới giờ, nghe toàn là rơi từ trên xuống không hà! Cái này là từ duới lên đây!
Code:
var no = 15; // image number or falling rate
var speed = 3; // the lower the number the faster the image moves
var snow = new Array();
snow[0] = "name.gif"
snow[1] = "name.gif"
snow[2] = "name.gif"

var ns4up = (document.layers) ? 1 : 0;  // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
var dx, xp, yp;    // coordinate and position variables
var am, stx, sty;  // amplitude and step variables
var i, doc_width = 800, doc_height = 1800;

if (ns4up||ns6up) {
        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();
j = 0;

for (i = 0; i < no; ++ i) {
        dx[i] = 0;                        // set coordinate variables
        xp[i] = Math.random()*(doc_width-50);  // set position variables
        yp[i] = Math.random()*doc_height;
        am[i] = Math.random()*20;         // set amplitude variables
        stx[i] = 0.02 + Math.random()/10; // set step variables
        sty[i] = 0.7 + Math.random();     // set step variables
        if (ns4up) {                      // set layers
                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||ns6up) {                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; }
}

function snowNS() {  // Netscape main animation function
        for (i = 0; i < no; ++ i) {  // iterate for every dot
                yp[i] -= sty[i];                if (yp[i] < -50) {
                        xp[i] = Math.random()*(doc_width-am[i]-30);
                        yp[i] = doc_height;
                        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 = yp[i]+pageYOffset;
                document.layers["dot"+i].left = xp[i] + 
am[i]*Math.sin(dx[i]);
        }
        setTimeout("snowNS()", speed);
}

function snowIE_NS6() {  // IE main animation function
        for (i = 0; i < no; ++ i) {  // iterate for every dot
                yp[i] -= sty[i];
                if (yp[i] < -50) {
                        xp[i] = Math.random()*(doc_width-am[i]-30);
                        yp[i] = doc_height;
                        stx[i] = 0.02 + Math.random()/10;
                        sty[i] = 0.7 + Math.random();
                        doc_width = ns6up?window.innerWidth-5:document.body.clientWidth;
                        doc_height = ns6up?window.innerHeight-5:document.body.clientHeight;
                }
                dx[i] += stx[i];
                if (ie4up){
                document.all["dot"+i].style.pixelTop = yp[i]+document.body.scrollTop;
                document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
                }
                else if (ns6up){
                document.getElementById("dot"+i).style.top=yp[i]+pageYOffset;
                document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
                }
        }
        setTimeout("snowIE_NS6()", speed);
}

if (ns4up) {
        snowNS();
} else if (ie4up||ns6up) {
        snowIE_NS6();
}
C++ viết 20:22 ngày 09/10/2018
Cám ơn mấy huynh nhiều lắm (không biết nói gì hơn)
đệ sẽ dùng thử xem
Bài liên quan
0