โค้ดหิมะตก บนเว็บสวยงาม

โพสต์โดย: admin | เมื่อ: 2015-1-9 03:20| เปิดอ่าน: 4398| ความคิดเห็น: 0

โค้ดหิมะตก บนเว็บสวยงาม
  1. <!-- หิมะตก-->
  2. <script>
  3. //Here you can add your own picture for snow. Just change the url
  4. var snowsrc="http://i13.servimg.com/u/f13/11/52/70/02/snowba10.png"
  5. //how many snowflakes there will be (currently 12)
  6. var no =47;
  7. //How fast will the snow disappear (0 is never)
  8. var hidesnowtime = 0;
  9. //The height the snow will reach before it disappears ("windowheight" or "pageheight")
  10. var snowdistance = "pageheight";
  11. ///////////////////////////////End of Settings///////////////////////////////////
  12. var ie4up = (document.all) ? 1 : 0;
  13. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  14. function iecompattest()
  15. {
  16. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  17. }
  18. var dx, xp, yp;
  19. var am, stx, sty;
  20. var i, doc_width = 800, doc_height = 600;
  21. if (ns6up)
  22. {
  23. doc_width = self.innerWidth;
  24. doc_height = self.innerHeight;
  25. }
  26. else
  27. if (ie4up)
  28. {
  29. doc_width = document.body.clientWidth;
  30. doc_height = document.body.clientHeight;
  31. }
  32. dx = new Array();
  33. xp = new Array();
  34. yp = new Array();
  35. am = new Array();
  36. stx = new Array();
  37. sty = new Array();
  38. for (i = 0; i < no; ++ i)
  39. {
  40. dx[i] = 0;
  41. xp[i] = Math.random()*(doc_width-50);
  42. yp[i] = Math.random()*doc_height;
  43. am[i] = Math.random()*20;
  44. stx[i] = 0.02 + Math.random()/10;
  45. sty[i] = 0.7 + Math.random();
  46. if (ie4up||ns6up)
  47. {
  48. if (i == 0)
  49. {
  50. document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;"><a href="http://rftactical.darkbb.com/index.htm"><img src='"+snowsrc+"' border="0"><\/a><\/div>");
  51. }
  52. else
  53. {
  54. document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;"><img src='"+snowsrc+"' border="0"><\/div>");
  55. }
  56. }
  57. }
  58. function snowIE_NS6()
  59. {
  60. doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
  61. doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
  62. for (i = 0; i < no; ++ i)
  63. {
  64. yp[i] += sty[i];
  65. if (yp[i] > doc_height-50)
  66. {
  67. xp[i] = Math.random()*(doc_width-am[i]-30);
  68. yp[i] = 0;
  69. stx[i] = 0.02 + Math.random()/10;
  70. sty[i] = 0.7 + Math.random();
  71. }
  72. dx[i] += stx[i];
  73. document.getElementById("dot"+i).style.top=yp[i]+"px";
  74. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
  75. }
  76. snowtimer=setTimeout("snowIE_NS6()", 10);
  77. }
  78. function hidesnow()
  79. {
  80. if (window.snowtimer) clearTimeout(snowtimer)
  81. for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
  82. }

  83. if (ie4up||ns6up)
  84. {
  85. snowIE_NS6();
  86. if (hidesnowtime>0)
  87. setTimeout("hidesnow()", hidesnowtime*1000)
  88. }
  89. </script>
คัดลอกไปที่คลิปบอร์ด


ตอบกระทู้ ขึ้นไปด้านบน ไปที่หน้ารายการกระทู้