Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Resetowanie czasu
Forum PHP.pl > Forum > PHP
szmerak
Mam taki kod na odliczanie czasu zaczyna się od 8 godzin i 19 sekund tylko po odświerzeniu on znowu się zeruje i od nowa liczy czy da się zrobić gdy strona nie jest włączona np.jak w ogame żeby czas dalej leciał i po odświerzeniu się nie resetował?
  1. </script><script language="javascript">
  2. var time = "0";
  3. var Marker = "false";
  4. timera = new Array();
  5. timerb = new Array();
  6. countdown();
  7.  
  8. function setDivText(c1, text) {
  9. document.getElementById(c1).innerHTML=text;
  10. }
  11.  
  12. function addTimer(seconds, divName, url) {
  13. // 3 Sekunden dazu
  14. timera[timera.length] = seconds;
  15. timerb[timerb.length] = divName;
  16. var url = url;
  17. }
  18.  
  19. function countdown() {
  20. //alert(location);
  21. for (i=0; i<timera.length;i++) {
  22. if (timera[i] > 0) {
  23. if (--timera[i] > 0) {
  24. lSeconds = timera[i]%60; // bisserl komplizierte Formatierung
  25. lMinutes = Math.floor(timera[i] / 60);
  26. lHours = Math.floor(lMinutes / 60);
  27. lMinutes%=60;
  28. lHours= ((lHours<10)?"0":"") + (lHours);
  29. lMinutes= ((lMinutes<10)?"0":"") + (lMinutes);
  30. lSeconds =((lSeconds<10)?"0":"") + (lSeconds);
  31. if(lMinutes>=59 && lSeconds>=0){setDivText(timerb[i], "<span><b>( " + lHours + ":" + lMinutes
  32.  
  33. + ":" + lSeconds +" )</b></span>");}
  34. else{setDivText(timerb[i], "<span><b>( " + lHours + ":" + lMinutes + ":" + lSeconds +"
  35.  
  36. )</b></span>");}
  37. }
  38. else {
  39. //setDivText(timerb[i], "<span class='rot'>bereit</span>");
  40. timera[i] += time; // als 'wieder frei' markieren
  41. window.location.href = location;
  42. }
  43. }
  44. else {
  45. //setDivText(timerb[i], "<span class='rot'>bereit</span>");
  46. timera[i] += time; // als 'wieder frei' markieren
  47. window.location.href = location;
  48. }
  49. }
  50. setTimeout("countdown()", 1000);
  51. }
  52.  
  53. function confirm_delete_cat(text,loc) {
  54. if (confirm(text)) {
  55. /* sehende Seite */
  56. location.href = loc;
  57. }
  58. }
  59.  
  60. function neuesFenster(URL,Name,Stats) {
  61. window.open(URL,Name,Stats)
  62. }
  63.  
  64. function CheckboxenAktivieren(field) {
  65. if(Marker=="false") {
  66. if(field.length){
  67. for(i=0; i<field.length; i++) {
  68. field[i].checked = true;
  69. }
  70. }
  71. else{
  72. field.checked = true;
  73. }
  74. Marker = "true";
  75. return "Alle De-Markieren";
  76. }
  77. else {
  78. if(field.length){
  79. for(i=0; i<field.length; i++) {
  80. field[i].checked = false;
  81. }
  82. }
  83. else{
  84. field.checked = false;
  85. }
  86. Marker = "false";
  87. return "Alle Markieren";
  88. }
  89. }
  90. <script language="JavaScript">
  91. function gamepay_item(url) {
  92. var new_win =
  93.  
  94. window.open(url,'Gamepay','resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=yes,width=820,height=8
    00,top=0,left=0');
  95.  
  96. new_win.focus();
  97. }
  98. <p><span id="4000"><script type="text/javascript">addTimer(28684,4000);</script></span></td></tr></table>
thornag
Po pierwsze wrzuc to w BBcode bo sie czytac nie da. Po drugie to jest JS nie php :/ Po trzecie mozesz wrzucic docelowy czas do bazy albo pliku i wyswietlac ile do finalu jeszcze zostalo.
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.