Phiên bản đầy đủ: jsB@nk » » Ảnh va chạm trong trình duyệt
URL: https://www.javascriptbank.com/new-year-script-floating-luckycharms.html
Hiệu ứng làm cho các ảnh bay khắp nơi và va chạm với các cạnh trong trang web, ảnh nào va chạm càng nhiều thì càng sớm mờ đi và biến mất.
Phiên bản đầy đủ: jsB@nk » » Ảnh va chạm trong trình duyệt
URL: https://www.javascriptbank.com/new-year-script-floating-luckycharms.html
<SCRIPT>// New-Year-Script: Floating Luckycharmsvar slideurl=new Array("logojs.gif","logojs.gif","logojs.gif","logojs.gif")var slidecomment=new Array("","","","","")var slidelink=new Array("#","#","#","#")var slidetarget=new Array()var slidefont="Arial"var slidefontcolor="black"var slidefontsize="1"var ns4=document.layers?1:0var ns6=document.getElementById&&!document.all?1:0 var ie=document.all?1:0var floatingspeed=10var tempo=20var numberofimages=slideurl.length-1var stepx=new Array()var stepy=new Array()for (i=0;i<=numberofimages;i++) {stepx[i]=randommaker(floatingspeed)stepy[i]=randommaker(floatingspeed)}var imgwidth=new Array()var imgheight=new Array()for (i=0;i<=numberofimages;i++) {imgwidth[i]=10imgheight[i]=10}var x,yvar marginbottomvar marginleft=0var margintop=0var marginrightvar timervar i_fadestrength=new Array()var i_fadestep=new Array()var i_fadenow=new Array()var i_fadenowmax=new Array()for (i=0;i<=slideurl.length;i++) {i_fadenowmax[i]=randommaker(10)+2i_fadestrength[i]=randommaker(99)i_fadestep[i]=1i_fadenow[i]=0}var spancontent=new Array()var imgpreload=new Array()for (i=0;i<=slideurl.length;i++) {imgpreload[i]=new Image()imgpreload[i].src=slideurl[i]}for (i=0;i<=numberofimages;i++) {spancontent[i]="<a href='"+slidelink[i]+"' target='"+slidetarget[i]+"'><img src='"+slideurl[i]+"' border='0'></a><br><font face='"+slidefont+"' color='"+slidefontcolor+"' size='"+slidefontsize+"'>"+slidecomment[i]+"</font>"}function setValues() {if (ie) { marginbottom=document.body.clientHeight-5 marginright=document.body.clientWidth-5for (i=0;i<=numberofimages;i++) { var thisspan = eval("document.all.span"+i) thisspan.innerHTML=spancontent[i]imgwidth[i]=thisspan.offsetWidthimgheight[i]=thisspan.offsetHeightvar maxleftstart=marginright-imgwidth[i]var maxtopstart=marginbottom-imgheight[i]var thisspan = eval("document.all.span"+(i)+".style")thisspan.visibility="visible" thisspan.posLeft=randommaker(maxleftstart)thisspan.posTop=randommaker(maxtopstart) }checkmovement()}if (ns6) { marginbottom=window.innerHeight-11 marginright=window.innerWidth-11for (i=0;i<=numberofimages;i++) { var thisspan=document.getElementById('span'+i)thisspan.innerHTML=spancontent[i]var thisspan=document.getElementById('span'+i)imgwidth[i]=parseInt(thisspan.offsetWidth)imgheight[i]=parseInt(thisspan.offsetHeight)var maxleftstart=marginright-imgwidth[i]var maxtopstart=marginbottom-imgheight[i]var thisspan=document.getElementById('span'+i).style thisspan.left=parseInt(thisspan.left)+randommaker(maxleftstart)thisspan.top=parseInt(thisspan.top)+randommaker(maxtopstart) thisspan.visibility="visible" } checkmovement()}}function randommaker(range) {rand=Math.floor(range*Math.random())if (rand==0) {rand=Math.ceil(range/2)} return rand}function checkmovement() {checkposition()movepictures() timer=setTimeout("checkmovement()",tempo)}function movepictures() {if (ie) {for (i=0;i<=numberofimages;i++) { var thisspan=eval("document.all.span"+(i)+".style") thisspan.posLeft+=stepx[i]thisspan.posTop+=stepy[i]var thisfilter=eval("span"+i)i_fadenow[i]++if (i_fadenow[i]>=i_fadenowmax[i]) {i_fadenow[i]=0if (i_fadestrength[i]>=100) {i_fadestep[i]=i_fadestep[i]*-1}else if (i_fadestrength[i]<=-20) {i_fadestep[i]=i_fadestep[i]*-1}}i_fadestrength[i]+=i_fadestep[i]thisfilter.filters.alpha.opacity=Math.round(i_fadestrength[i]) }}if (ns6) {for (i=0;i<=numberofimages;i++) { var thisspan=document.getElementById('span'+i).style thisspan.left=parseInt(thisspan.left)+stepx[i]thisspan.top=parseInt(thisspan.top)+stepy[i]i_fadenow[i]++if (i_fadenow[i]>=i_fadenowmax[i]) {i_fadenow[i]=0if (i_fadestrength[i]>=100) {i_fadestep[i]=i_fadestep[i]*-1}else if (i_fadestrength[i]<=-20) {i_fadestep[i]=i_fadestep[i]*-1}}i_fadestrength[i]+=i_fadestep[i]document.getElementById('span'+i).style.MozOpacity=Math.round(i_fadestrength[i])/100 }}}function checkposition() {if (ie) {for (i=0;i<=numberofimages;i++) { var thisspan=eval("document.all.span"+i+".style")if (thisspan.posLeft>marginright-imgwidth[i]-floatingspeed) {thisspan.posLeft-=Math.abs(stepx[i]+1)stepx[i]=randommaker(floatingspeed)*-1}if (thisspan.posLeft<marginleft) {thisspan.posLeft+=Math.abs(stepx[i])stepx[i]=randommaker(floatingspeed)}if (thisspan.posTop>marginbottom-imgheight[i]-floatingspeed) {thisspan.posTop-=Math.abs(stepy[i])stepy[i]=randommaker(floatingspeed)*-1}if (thisspan.posTop<margintop) {thisspan.posTop+=Math.abs(stepy[i])stepy[i]=randommaker(floatingspeed)}}}if (ns6) {for (i=0;i<=numberofimages;i++) { imgwidth[i]=parseInt(document.getElementById('span'+i).offsetWidth)imgheight[i]=parseInt(document.getElementById('span'+i).offsetHeight) var thisspan=document.getElementById('span'+i).stylevar leftx=parseInt(thisspan.left)var topy=parseInt(thisspan.top)if (leftx>marginright-imgwidth[i]-floatingspeed) {thisspan.left=leftx-Math.abs(stepx[i]+1)stepx[i]=randommaker(floatingspeed)*-1}if (leftx<marginleft) {thisspan.left=leftx+Math.abs(stepx[i])stepx[i]=randommaker(floatingspeed)}if (topy>marginbottom-imgheight[i]-floatingspeed) {thisspan.top=topy-Math.abs(stepy[i])stepy[i]=randommaker(floatingspeed)*-1}if (topy<margintop) {thisspan.top=topy+Math.abs(stepy[i])stepy[i]=randommaker(floatingspeed)}}}}if (ie || ns6) {for (i=0;i<=numberofimages;i++) { document.write("<span id='span"+i+"' style='position:absolute;top:0px;left:0px;filter:alpha(opacity=0);-moz-opacity:0'; visibility:hidden></span>") document.close()}window.onload=setValues}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->