ANWENDUNGSBEISPIEL
Die Uhrzeit wird im normalen Text eingebunden
Die Uhrzeit wird im normalen Text eingebunden
und benötigt keine besondere Formatierung.
Zurück zur Script-Auswahl oder dieses
Script-Archiv laden?
EINBINDUNG DES SCRIPTS IN DEINE HOMEPAGE:
Falls Du das Script-Archiv bereits geladen hast, so brauchst Du jetzt nicht
mehr weiterzulesen. Das Archiv enthält auch diese Beispieldatei
(textuhr.html) und kann deshalb Offline durchgesehen werden.
- Das vorliegende Script besteht aus zwei Teilen:
1. Einem Java-Script im Head-Teil.
2. Dem Funktionsaufruf im Body-Bereich.
- Das JAVA-Script für den "HEAD"-Teil sieht folgendermaßen aus:
(Groß- und Kleinschreibung muß beachtet werden!)
<META http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
<!-- Start JavaScript -
// CREDITS:
// Inline clock: fits anywhere into any text
// by Urs Dudli and Peter Gehrig
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com
// info@24fun.com
// 7/5/2001
// IMPORTANT:
// If you add this script to a script-library or a script-archive
// you have to insert a link to http://www.24fun.com
// right into the webpage where the script will be displayed.
// CONFIGURATION:
// Go to http://www.24fun.com, open category 'date' and
// download the ZIP-file of this script containing
// the script-file with step-by-step instructions for easy configuration
var clockid=new Array()
var clockidoutside=new Array()
var i_clock=-1
var thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
var thistime = hours+":"+minutes+":"+seconds
function writeclock() {
i_clock++
if (document.all || document.getElementById || document.layers) {
clockid[i_clock]="clock"+i_clock
document.write("<span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span>")
}
}
function clockon() {
thistime= new Date()
hours=thistime.getHours()
minutes=thistime.getMinutes()
seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds
if (document.all) {
for (i=0;i<=clockid.length-1;i++) {
var thisclock=eval(clockid[i])
thisclock.innerHTML=thistime
}
}
if (document.getElementById) {
for (i=0;i<=clockid.length-1;i++) {
document.getElementById(clockid[i]).innerHTML=thistime
}
}
var timer=setTimeout("clockon()",1000)
}
window.onload=clockon
// - Ende JavaScript - -->
</script>
- Der Funktionsaufruf im Body-Bereich sieht folgendermaßen aus:
<script>writeclock()</script>
- Hinweise zur individuellen Anpassung
Ganz einfach: Es gibt nichts zum Anpassen. Du kopierst die beiden Teile wie vorgesehen in
Deine HTML-Seite.
An der Position, an der Du den Funktionsaufruf einbindest, erscheint beim Seitenaufruf die
Uhrzeit im gleichen Format, wie der Text drumherum.
Selbstverständlich könntest Du die Uhrzeit mit den üblichen
HTML-Tags auch abweichend formatieren.
Die Autoren sind Peter Gehrig und Urs Dudli.
Auf ihrer HomePage:
http://www.24fun.com findest Du weitere tolle Skripts!