Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JS] Płatki śniegu na stronie - problem
Forum PHP.pl > Forum > Przedszkole
sw04
taki problem mam
mam skrypt ktory "wypuszcza" z gory strony platki sniegu. problem w tym ze zamiast na samym dole to traca sie one gdzies po ok. 70%. tzn przez pierwsze 70% strony platki sa, nizej juz nei blinksmiley.gif
da rade zrobic zeby pokazywaly sie na calej stronie? sadsmiley02.gif

zamieszczam kod smile.gif

pozdrawiam

ps. nie ma przycisku do pokazywania JS wiec uzylem opcji do php



  1. <?php
  2. <script language="JavaScript1.2">
  3.  
  4. /*
  5. Snow Effect Script
  6. Submitted by Altan d.o.o. (snow@altan.hr, <a href=\"http://www.altan.hr/snow/index.html)\" target=\"_blank\">http://www.altan.hr/snow/index.html)</a>
  7. Permission granted to Dynamicdrive.com to feature script in archive
  8. For full source code to this script, visit <a href=\"http://dynamicdrive.com\" target=\"_blank\">http://dynamicdrive.com</a>
  9. */
  10.  
  11.  
  12. //Configure below to change URL path to the snow image
  13. var snowsrc="http://img506.imageshack.us/img506/4899/snieg5cg.gif"
  14. // Configure below to change number of snow to render
  15. var no = 10;
  16.  
  17. var ns4up = (document.layers) ? 1 : 0; // browser sniffer
  18. var ie4up = (document.all) ? 1 : 0;
  19. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  20.  
  21. var dx, xp, yp; // coordinate and position variables
  22. var am, stx, sty; // amplitude and step variables
  23. var i, doc_width = 1024, doc_height = 768;
  24.  
  25. if (ns4up||ns6up) {
  26. doc_width = self.innerWidth;
  27. doc_height = self.innerHeight;
  28. } else if (ie4up) {
  29. doc_width = document.body.clientWidth;
  30. doc_height = document.body.clientHeight;
  31. }
  32.  
  33. dx = new Array();
  34. xp = new Array();
  35. yp = new Array();
  36. am = new Array();
  37. stx = new Array();
  38. sty = new Array();
  39.  
  40. for (= 0; i < no; ++ i) {
  41. dx[i] = 0; // set coordinate variables
  42. xp[i] = Math.random()*(doc_width-10); // set position variables
  43. yp[i] = Math.random()*doc_height;
  44. am[i] = Math.random()*20; // set amplitude variables
  45. stx[i] = 0.02 + Math.random()/10; // set step variables
  46. sty[i] = 0.+ Math.random(); // set step variables
  47. if (ns4up) { // set layers
  48. if (== 0) {
  49. document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><a href=\"http://dynamicdrive.com/\"><img src='"+snowsrc+"' border=\"0\"></a></layer>");
  50. } else {
  51. document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
  52. }
  53. } else if (ie4up||ns6up) {
  54. if (== 0) {
  55. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"></a></div>");
  56. } else {
  57. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
  58. }
  59. }
  60. }
  61.  
  62. function snowNS() { // Netscape main animation function
  63. for (= 0; i < no; ++ i) { // iterate for every dot
  64. yp[i] += sty[i];
  65. if (yp[i] > doc_height-50) {
  66. xp[i] = Math.random()*(doc_width-am[i]-30);
  67. yp[i] = 0;
  68. stx[i] = 0.02 + Math.random()/10;
  69. sty[i] = 0.+ Math.random();
  70. doc_width = self.innerWidth;
  71. doc_height = self.innerHeight;
  72. }
  73. dx[i] += stx[i];
  74. document.layers["dot"+i].top = yp[i];
  75. document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
  76. }
  77. setTimeout("snowNS()", 10);
  78. }
  79.  
  80. function snowIE_NS6() { // IE and NS6 main animation function
  81. for (= 0; i < no; ++ i) { // iterate for every dot
  82. yp[i] += sty[i];
  83. if (yp[i] > doc_height-50) {
  84. xp[i] = Math.random()*(doc_width-am[i]-10);
  85. yp[i] = 0;
  86. stx[i] = 0.02 + Math.random()/10;
  87. sty[i] = 0.+ Math.random();
  88. doc_width = ns6up?window.innerWidth : document.body.clientWidth;
  89. doc_height = ns6up?window.innerHeight : document.body.clientHeight;
  90. }
  91. dx[i] += stx[i];
  92. if (ie4up){
  93. document.all["dot"+i].style.pixelTop = yp[i];
  94. document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
  95. }
  96. else if (ns6up){
  97. document.getElementById("dot"+i).style.top=yp[i];
  98. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
  99. }
  100. }
  101. setTimeout("snowIE_NS6()", 10);
  102. }
  103.  
  104. if (ns4up) {
  105. snowNS();
  106. } else if (ie4up||ns6up) {
  107. snowIE_NS6();
  108. }
  109.  
  110. </script>
  111. ?>
Sadu2
Nie znam sie na js, ale czy tu sie nie ustala czegos?

  1. <?php
  2. var i, doc_width = 1024, doc_height = 768;
  3. ?>
xbigos
Kod
<?php
var i, doc_width = 1024, doc_height = 768;
?>

zmien doc_height na 786
Tez za dobry w js-ie nie jestem:) ale wydaje mi sie ze powinno pomóc
sw04
niestety, zmiana tego parametru niczego nie zmienia - snieg caly czas spada do ok 70% strony... sad.gif
dadexix
Cytat
Kod
<?php
var i, doc_width = 1024, doc_height = 768;
?>

zmien doc_height na 786
czy po tej zmianie zmieniła się "ilość" śniegu? dokładniej mówiąc czy jest cały czas tyle samo śniegu czy więcej śniegu o 20px strony?
sw04
Cytat(dadexix @ 21.12.2007, 19:18:02 ) *
czy po tej zmianie zmieniła się "ilość" śniegu? dokładniej mówiąc czy jest cały czas tyle samo śniegu czy więcej śniegu o 20px strony?


wstawialem tam rozne liczby (1, 700, 1000, 10000) i nie zauwazylem zbytniej roznicy roznicy - byc moze jest taka mala... sadsmiley02.gif
Chrom
Problem tkwi tutaj
  1. <?php
  2. if (yp[i] > doc_height-50)
  3. ?>

masz to w dwóch miejscach zmień 50 na 5
sw04
Cytat(Chrom @ 21.12.2007, 21:33:49 ) *
Problem tkwi tutaj
  1. <?php
  2. if (yp[i] > doc_height-50)
  3. ?>

masz to w dwóch miejscach zmień 50 na 5


teraz, wydaje mi sie, ze leca z 2-3cm nizej, ale dalej nie na sam dol blinksmiley.gif
Chrom
to daj + 50
pokombinuj
Liko
  1. <script type="text/javascript">
  2.  
  3. /******************************************
  4. * Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)
  5. * Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code
  6. * Last updated Nov 9th, 05' by DD. This notice must stay intact for use
  7. ******************************************/
  8.  
  9. //Configure below to change URL path to the snow image
  10. var snowsrc="http://img506.imageshack.us/img506/4899/snieg5cg.gif"
  11. // Configure below to change number of snow to render
  12. var no = 10;
  13. // Configure whether snow should disappear after x seconds (0=never):
  14. var hidesnowtime = 0;
  15. // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  16. var snowdistance = "pageheight";
  17.  
  18. ///////////Stop Config//////////////////////////////////
  19.  
  20. var ie4up = (document.all) ? 1 : 0;
  21. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  22.  
  23. function iecompattest(){
  24. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  25. }
  26.  
  27. var dx, xp, yp; // coordinate and position variables
  28. var am, stx, sty; // amplitude and step variables
  29. var i, doc_width = 800, doc_height = 600;
  30.  
  31. if (ns6up) {
  32. doc_width = self.innerWidth;
  33. doc_height = self.innerHeight;
  34. } else if (ie4up) {
  35. doc_width = iecompattest().clientWidth;
  36. doc_height = iecompattest().clientHeight;
  37. }
  38.  
  39. dx = new Array();
  40. xp = new Array();
  41. yp = new Array();
  42. am = new Array();
  43. stx = new Array();
  44. sty = new Array();
  45. snowsrc=(snowsrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : snowsrc
  46. for (i = 0; i < no; ++ i) {
  47. dx[i] = 0; // set coordinate variables
  48. xp[i] = Math.random()*(doc_width-50); // set position variables
  49. yp[i] = Math.random()*doc_height;
  50. am[i] = Math.random()*20; // set amplitude variables
  51. stx[i] = 0.02 + Math.random()/10; // set step variables
  52. sty[i] = 0.7 + Math.random(); // set step variables
  53. if (ie4up||ns6up) {
  54. if (i == 0) {
  55. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
  56. } else {
  57. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
  58. }
  59. }
  60. }
  61.  
  62. function snowIE_NS6() { // IE and NS6 main animation function
  63. doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
  64. doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
  65. for (i = 0; i < no; ++ i) { // iterate for every dot
  66. yp[i] += sty[i];
  67. if (yp[i] > doc_height-50) {
  68. xp[i] = Math.random()*(doc_width-am[i]-30);
  69. yp[i] = 0;
  70. stx[i] = 0.02 + Math.random()/10;
  71. sty[i] = 0.7 + Math.random();
  72. }
  73. dx[i] += stx[i];
  74. document.getElementById("dot"+i).style.top=yp[i]+"px";
  75. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
  76. }
  77. snowtimer=setTimeout("snowIE_NS6()", 10);
  78. }
  79.  
  80. function hidesnow(){
  81. if (window.snowtimer) clearTimeout(snowtimer)
  82. for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
  83. }
  84.  
  85.  
  86. if (ie4up||ns6up){
  87. snowIE_NS6();
  88. if (hidesnowtime>0)
  89. setTimeout("hidesnow()", hidesnowtime*1000)
  90. }
  91.  
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.