Weihnachts-Countdown-Zähler gesucht
#2
http://www.emailsanta.com/clock.asp

Code:
Instructions for creating your own "Countdown to Christmas Clock" as seen at http://www.emailsanta.com/clock.asp.

There are 3 steps to creating your own countdown clock.  Each step is discussed in turn below and must be carefully followed in order for the script to work.  A "SAMPLE FULL PAGE CODE" is provided at the end.

NOTES:

·  Make sure to cut and paste the code below from Notepad with word wrap off so that the code does not become garbled (e.g. converts "<" to "&lt;").
·  Because this code is javascript, it ONLY works inside an HTML or similar web page (e.g. .htm, .asp etc.).
·  A link to www.EmailSanta.com on your page is appreciated.  Here is some sample code to cut & paste:

<p><a href="http://www.emailsanta.com/">EmailSanta:</a> Send your Christmas Wish to Santa Claus!</p>

·  Save your work!  This code is provided "as is".  EmailSanta is not responsible for its use.
·  To change the message that appears between Christmas and New Years, change the msg for "var myMainMessage" (The clock automatically resets on January 1st.)
·  CSS can be used to format the text & background colour etc. of the countdown clock.



Step 1.  Put the JavaScript code appearing between the asterisks between the "<head>" & "</head>" tags of your page.  

************************

<script type="text/javascript"><!--
//<![CDATA[
var startPosition=0;

function Xmascountdown()
{
var XmasDay = "December 25,"
var today = new Date()
var thisYear = today.getFullYear()
var XmasDate = new Date(XmasDay + thisYear)
var diff = XmasDate.getTime() - today.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));

if ((days < 0) && (days >= -1)) {
var myMainMessage=" M E R R Y   C H R I S T M A S   F R O M   T H E   E L V E S   A T   E M A I L S A N T A . C O M !!! ...";
var speed=175;
var scrollingRegion=100;
var mainMessage=myMainMessage;
var tempLoc=(scrollingRegion*3/mainMessage.length)+1;
var aut="emsanta"
if (tempLoc<1) {tempLoc=1}
var counter;
for(counter=0;counter<=tempLoc;counter++);
mainMessage+=mainMessage;
document.clock.Xmascountdown.value =mainMessage.substring(startPosition,startPosition+scrollingRegion);
startPosition++;
if(startPosition>scrollingRegion) startPosition=0;
setTimeout("Xmascountdown()",speed);
}

else {
if (days >= 0) {
var theDay = XmasDate;
}
else {
var theDay = new Date(XmasDate.getYear()+1,XmasDate.getMonth(),XmasDate.getDate());
}
var second = Math.floor((theDay.getTime() - today.getTime())/1000);
var minute = Math.floor(second/60);
var hour = Math.floor(minute/60);
var day = Math.floor(hour/24);
CDay= day;
CHour= hour % 24;
CMinute= minute % 60;
CSecond= second % 60;
var DayTill =  CDay + " days, " + CHour + " hours, " + CMinute + " minutes and " + CSecond + " seconds ";
document.clock.Xmascountdown.value = DayTill;
var counter = setTimeout("Xmascountdown()", 1000);
}
}
//]]>
//-->
</script>

************************

Step 2.  Replace the "<body>" tag of your page with the following code between asterisks (or add the "onload..." portion to your existing <body> tag if there is already other info in it).  NOTE:  a valid web page cannot have 2 BODY tags!

************************
<body onload="Xmascountdown()">
************************

Step 3.  Place the following code snippet wherever you'd like the clock to appear on your page.  You can add whatever else you want to the page, just make sure the following code appears on the page and everything should work ok.

************************
   <form name="clock">
    <input type="TEXT" size="45" name="Xmascountdown">
   </form>
************************



************************
SAMPLE FULL PAGE CODE
************************
<html>
<head>
<script language="javascript" type="text/javascript"><!--
//<![CDATA[
var startPosition=0;

function Xmascountdown()
{
var XmasDay = "December 25,"
var today = new Date()
var thisYear = today.getFullYear()
var XmasDate = new Date(XmasDay + thisYear)
var diff = XmasDate.getTime() - today.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));

if ((days < 0) && (days >= -1)) {
var mainMessage =" M E R R Y   C H R I S T M A S   F R O M   T H E   E L V E S   A T   E M A I L S A N T A . C O M !!! ... ";
var speed=175;
var scrollingRegion=100;
var tempLoc=(scrollingRegion*3/mainMessage.length)+1;
if (tempLoc<1) {tempLoc=1}
var aut="emsanta"
var counter;
for(counter=0;counter<=tempLoc;counter++);
mainMessage+=mainMessage;
document.clock.Xmascountdown.value =mainMessage.substring(startPosition,startPosition+scrollingRegion);
startPosition++;
if(startPosition>scrollingRegion) startPosition=0;
setTimeout("Xmascountdown()",speed);
}

else {
if (days >= 0) {
var theDay = XmasDate;
} else {
var theDay = new Date(XmasDate.getYear()+1,XmasDate.getMonth(),XmasDate.getDate());
}
var second = Math.floor((theDay.getTime() - today.getTime())/1000);
var minute = Math.floor(second/60);
var hour = Math.floor(minute/60);
var day = Math.floor(hour/24);
CDay= day;
CHour= hour % 24;
CMinute= minute % 60;
CSecond= second % 60;
var DayTill =  CDay + " days, " + CHour + " hours, " + CMinute + " minutes and " + CSecond + " seconds";
document.clock.Xmascountdown.value = DayTill;
var counter = setTimeout("Xmascountdown()", 1000);
}
}
//]]>
//-->
</script>
</head>

<body onload="Xmascountdown();">

   <form name="clock">
    <p><input name="Xmascountdown" size="45"></p>
   </form>
<p><a href="http://www.emailsanta.com/">EmailSanta:</a> Send your Christmas Wish to Santa Claus!</p>
</body>
</html>
Zitieren



Nachrichten in diesem Thema
Weihnachts-Countdown-Zähler gesucht - von Pedro - 20.09.2008, 04:28
Weihnachts-Countdown-Zähler gesucht - von Ebba - 20.09.2008, 22:16
Weihnachts-Countdown-Zähler gesucht - von Osiris - 30.10.2008, 11:32
Weihnachts-Countdown-Zähler gesucht - von hsk - 30.10.2008, 12:43
Weihnachts-Countdown-Zähler gesucht - von Osiris - 30.10.2008, 13:19

Möglicherweise verwandte Themen...
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Vertrauen - Bergsteiger gesucht Heinzi 4 2.309 10.07.2019, 18:12
Letzter Beitrag: norre
  Altes Urlaubsfoto gesucht Heinzi 0 851 30.04.2018, 20:57
Letzter Beitrag: Heinzi
  Grafiksoftware gesucht MacRubino 13 3.762 04.04.2016, 21:32
Letzter Beitrag: Jürgen
  Präsentationsmappen - Profi Tipp gesucht Georg62 10 3.034 22.03.2016, 15:09
Letzter Beitrag: mvm
  Dozenten gesucht Ramona 0 787 07.05.2014, 13:48
Letzter Beitrag: Ramona
  Drache gesucht Georg62 8 2.327 02.04.2014, 11:31
Letzter Beitrag: Georg62
  (Weihnachts-)Schriften kostenlos Nachtviole 2 2.453 10.12.2013, 11:09
Letzter Beitrag: Unkraut
  Gesucht: Investoren für Wegwerf-Kamera! hsk 1 1.219 19.11.2013, 09:47
Letzter Beitrag: morphsuite
  Mitfahrgelegenheit gesucht Arlena 0 858 23.07.2013, 07:47
Letzter Beitrag: Arlena
  Weihnachts Icons Georg62 2 1.221 03.12.2012, 10:46
Letzter Beitrag: Pywi