Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
[JavaScript] Modyfikacja skryptu
#1
Mam skrypt, który odmierza czas do określonej daty, ale w rzeczywistości nie zmieniają się godziny i minuty. Czy mógłby mi ktoś pomóc go naprawić?
Kod:
SCRIPT language="JavaScript">
<!--
today = new Date("March 13, 2012");
BigDay = new Date("April 20, 2012")
msPerDay = 24 * 60 * 60 * 1000 ;
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);
var id,pause=0,position=0;
function imascroller() {
        var i,k,msg="Już za " +daysLeft+" dni, "+hrsLeft+" godzin(y) i "+minsLeft+" minut(y) Gerard będzie obchodził urodziny. Nie zapomnij o życzeniach w tym dniu! I bądź dla niego miły/a! :)                                                                                           ";
        k=(150/msg.length)+1;
        for(i=0;i<=k;i++) msg+=" "+msg;
document.form2.imascroller.value=msg.substring(position,position+300);
        if(position++==300) position=0;
        id=setTimeout("imascroller()",200); }
-->
</SCRIPT>
<FORM NAME="form2">
<CENTER><INPUT TYPE="text" NAME="imascroller" SIZE="90" value=""></CENTER>
</FORM>
<SCRIPT language=JavaScript1.1>
timerID = setTimeout("location.reload()",60000)
</SCRIPT>
<SCRIPT language=JavaScript>
timerID = setTimeout("history.go(0)",60000)
imascroller()
</SCRIPT>

I jeszcze drugi skrypt. Jak zrobić, aby cytaty zmieniały się dopiero następnego dnia (chciałabym mieć bazę cytatów na cały miesiąc), a nie przy każdym odświeżeniu strony?
Kod:
<SCRIPT LANGUAGE="JavaScript">
<!--
//store the quotations in arrays
//author: [email protected]
quotes = new Array(6);
authors = new Array(6);
quotes[0] = "Nie ma życia na żarty, że wiek dziecięcy - to długie i ważne lata żywota człowieka.";
authors[0] = "Charles Schulz";
quotes[1] = "Reality is the leading cause of stress for those in touch with it.";
authors[1] = "Jack Wagner";
quotes[2] = "Few things are harder to put up with than the annoyance of a good example.";
authors[2] = "Mark Twain";
quotes[3] = "The pure and simple truth is rarely pure and never simple.";
authors[3] = "Oscar Wilde";
quotes[4] = "There's no business like show business, but there are several businesses like accounting.";
authors[4] = "David Letterman";
quotes[5] = "Man invented language to satisfy his deep need to complain.";
authors[5] = "Lily Tomlin";

//calculate a random index
index = Math.floor(Math.random() * quotes.length);
//display the quotation
document.write("<DL>\n");
document.write("<DT><I>" + "\"" + quotes[index] + "\"</I>\n");
document.write("<DD>" + "-- " + authors[index] + "\n");
document.write("</DL>\n");
//done
//-->
</SCRIPT>
Odpowiedz


Wiadomości w tym wątku
[JavaScript] Modyfikacja skryptu - przez ania12345 - 14-03-2012, 00:53

Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Czy ilość zmiennych w javascript, jako języku interpretowanym, ma znaczenie? Jakie gburhiphop 22 22,609 09-09-2016, 21:09
Ostatni post: Ribana
Toungue Problem z nie działającym javascript Radian 4 4,859 20-03-2015, 16:31
Ostatni post: Radian
  JavaScript podstawy bryndzyk 5 4,229 18-05-2013, 21:17
Ostatni post: ferrante
  JavaScript Gmaps Api Rysowanie Squezzer 0 2,080 16-05-2013, 18:18
Ostatni post: Squezzer
  itegracja lightboxa z "like button" z JavaScript SDK sakkada 4 4,801 04-01-2013, 01:39
Ostatni post: sakkada

Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości
Sponsorzy i przyjaciele
SeoHost.pl