Total verzweifelt (window.onload)

  • Ersteller Ersteller User0
  • Erstellt am Erstellt am
U

User0

Gast
Mit dem folgendem Script:
Code:
var heute = new Date();
var jahr = heute.getYear();
var monat = heute.getMonth()+1;
var tag = heute.getDate();
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 zeit(){
i_clock++
if (document.all || document.getElementById || document.layers) {
clockid[i_clock]="clock"+i_clock
document.write("<font id='"+clockid[i_clock]+"'>"+thistime+"</font>")}}
function uhr(){

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("uhr()",1000)
}

window.onload = uhr()


function datum(){
var today = new Date();
var month = today.getMonth()+1;
var year = today.getYear();
var day = today.getDate();
if(day<10) day = "0" + day;
if(month<10) month= "0" + month;
if(year<1000) year+=1900;
document.write(""+ day + "."+ month + "." + year +"");
}

funktioniert zwar alles wie gewollt, aber im Browser (IE) meckert er an dieser Stelle (1.Zeichen, also w):
Code:
window.onload = uhr()


Haltet mich nicht für zu dumm aber ich sitze seid stunde ndaran und komme nicht drauf was den Scriptfehler hervorrufen tut, funktionieren tut alles aber dennoch fehlt was oder ist an falscher Stellle mit window.onload

Mag mir jemand vom leiden erlösen ich dreh durch langsam. *seuftz

Lieben Gruss
 
Wenn ich die weglasse funktionieren die Sekunden nicht im IE aber im Firefox schon, aber nur durch die () funktionieren die sekunden im IE :-(
 
mach halt ne browserabfrage, die das dann anpasst...
 
Siehe oben. Im Link sollte alles drinstehen, was dir hilft, das window.onload-Problem zu beheben.
 
Bei C++ würde ich ein "void" in die Klammer schreiben....
:)

Also window.onload = uhr (void)
 
Marius schrieb:
Bei C++ würde ich ein "void" in die Klammer schreiben....
:)

Also window.onload = uhr (void)
Geht garnicht mehr dann

Stinger schrieb:
mach halt ne browserabfrage, die das dann anpasst...

Wie und wo? Lieb fragt
Ergänzung ()

Der vollständigkeit hier mal Alles im Komplett: datetime.js
Code:
var heute = new Date();
var jahr = heute.getYear();
var monat = heute.getMonth()+1;
var tag = heute.getDate();
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 zeit(){
i_clock++
if (document.all || document.getElementById || document.layers) {
clockid[i_clock]="clock"+i_clock
document.write("<font id='"+clockid[i_clock]+"'>"+thistime+"</font>")}}
function uhr(){

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("uhr()",1000)
}

window.onload = uhr()
######HIER KOMMT FEHLER - NICHT IMPLENTIERT######

function datum(){
var today = new Date();
var month = today.getMonth()+1;
var year = today.getYear();
var day = today.getDate();
if(day<10) day = "0" + day;
if(month<10) month= "0" + month;
if(year<1000) year+=1900;
document.write(""+ day + "."+ month + "." + year +"");
}

Dann hier mein Body:
Code:
onload="window.setTimeout('uhr()',1000)"

Hier Rest:
Code:
<form style="position: relative; left: 8px; top: 2px"><script type="text/javascript">datum()</script></form>

<form style="position: relative; left: 16px; top: 2px"><script type="text/javascript">zeit()</script></form>
 
Zuletzt bearbeitet von einem Moderator: (zusatz)
Wieso endet bei dir ein Befehl manchmal mit ; und manchmal nicht? Find ich irgendwie seltsam. Weiter weiss ich nicht für was du nen eigenen Eventlistener brauchst wenn du den sowieso im <body>-Tag definierst?
 
Ich habs geschafft, nachdem ich von UTF-8 auf ISO-8859-1 und alles klappt, bedanke mich für Eure Hilfe. LG Screamdad
 
Zuletzt bearbeitet von einem Moderator:
Zurück
Oben