Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript] Jak zmodifikować
Forum PHP.pl > Forum > Przedszkole
marcinn12
Cytat
W ramach HEAD
<script type="text/javascript"><!-- // start hiding

//BigDay = new Date("January 1, 2001");
BigDay = new Date(2001,0,1);
msPerDay = 24 * 60 * 60 * 1000 ;
var id,pause=0, position=0;

function showtime() {
today = new Date();
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
tdays = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
}

function Liczebnik( ile, rdzen, konc1, konc2, konc5 ) { // Autor Romuald Zylla
var N0, N1, N2, R0;
  N0 = Math.floor( Math.abs( ile ) ); // funkcja ma sens dla liczb całkowitych
  N1 = N0 % 10;
  N2 = N0 % 100;
  R0 = konc1;
  if (N0 == 1) R0 = konc1
 else if ((N2 > 4) && (N2 < 22)) R0 = konc5
  else if ((N1 > 1) && (N1 <= 4)) R0 = konc2
  else R0 = konc5;
  return rdzen + R0;
}

function imascroller() {
 // variables declaration
  var i, k;
  showtime();

 // Prosze zwrocic uwage na uzycie funkcji Liczebnik do generowania koncowek
  var msg= " "+Liczebnik( daysLeft, "Został"," ","y ","o " ) +
 daysLeft+Liczebnik( daysLeft, " ","dzien, ","dni, ","dni, " ) +
 hrsLeft +Liczebnik( hrsLeft," godzin", "a","y","" ) +" i "+
 minsLeft+Liczebnik( minsLeft," minut", "a ","y "," " )+" do trzeciego tysiąclecia!"+
 " ";
 // increase msg
  k=(150/msg.length)+1;
  for(i=0;i<=k;i++) msg+=" "+msg;
 // show it to the window

  document.forms[0].imascroller.value=msg.substring(position,position+300);
 // set new position
  if (position ++== 300) position = 0;
 // repeat at entered speed
  id = setTimeout( "imascroller()", 200 ); 
}
 // End Hiding Here -->
</script>

Na początku w znaczniku BODY należy jeszcze dodać
<body onload="imascroller()">

W ciele strony należy dodać wywołanie okienka z tekstem
<form ID="form2" action=get>
<input type="text" name="imascroller" size="60" value="">
</form>




Jak to zmodifikować, żeby tekst był nieruchomy?
neverever
  1. <script type="text/javascript"><!-- // start hiding
  2.  
  3. //BigDay = new Date("January 1, 2001");
  4. BigDay = new Date(2001,0,1);
  5. msPerDay = 24 * 60 * 60 * 1000 ;
  6. var id,pause=0, position=0;
  7.  
  8. function showtime() {
  9. today = new Date();
  10. timeLeft = (BigDay.getTime() - today.getTime());
  11. e_daysLeft = timeLeft / msPerDay;
  12. daysLeft = Math.floor(e_daysLeft);
  13. tdays = Math.floor(e_daysLeft);
  14. e_hrsLeft = (e_daysLeft - daysLeft)*24;
  15. hrsLeft = Math.floor(e_hrsLeft);
  16. minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
  17. }
  18.  
  19. function Liczebnik( ile, rdzen, konc1, konc2, konc5 ) { // Autor Romuald Zylla
  20. var N0, N1, N2, R0;
  21. N0 = Math.floor( Math.abs( ile ) ); // funkcja ma sens dla liczb całkowitych
  22. N1 = N0 % 10;
  23. N2 = N0 % 100;
  24. R0 = konc1;
  25. if (N0 == 1) R0 = konc1
  26. else if ((N2 > 4) && (N2 < 22)) R0 = konc5
  27. else if ((N1 > 1) && (N1 <= 4)) R0 = konc2
  28. else R0 = konc5;
  29. return rdzen + R0;
  30. }
  31.  
  32. function imascroller() {
  33. showtime();
  34. var msg= " "+Liczebnik( daysLeft, "Został"," ","y ","o " ) +
  35. daysLeft+Liczebnik( daysLeft, " ","dzien, ","dni, ","dni, " ) +
  36. hrsLeft +Liczebnik( hrsLeft," godzin", "a","y","" ) +" i "+
  37. minsLeft+Liczebnik( minsLeft," minut", "a ","y "," " )+" do trzeciego tysiąclecia!"+
  38. " ";
  39. document.forms[0].imascroller.value=msg;
  40.  
  41. }
  42. // End Hiding Here -->
marcinn12
YY nie dziala a dodatkowo wyskoczyl mi blad ak wchodze na strone:



Parse error: syntax error, unexpected $end in /var/www/sites/yoyo.pl/m/a/marcinn12/konkurs/twst.php on line 238

Padla i cala strona teraz ;( nawet po wyrzueniu tego kodu nie chce sie zaladowac ;/

Mialem kilka skryptow i chyba sie jakos poplataly. Wgrałem to na czysto i działa ale chcialbym ten napis wysrodkowac i dac na czerwono. Wyokonalne?

Dodano:
I zeby sie samo odswiezalo albo zeby seundy lecialy? Da rade:>?
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.