Hallo,
ich habe eine Lösung für dieses Problem gefunden.
Der Code darf nicht im Head stehen sondern muss im Body integriert werden.
Beispiel:
HTML-Code:
<body onload="alert('BODY');">
<h1>addOnload Test</h1>
<script type="text/javascript">
<!--
function addOnload(onloadFunc) {
// based on http://answers.google.com/answers/threadview?id=510976
if(this.addEventListener) {
this.addEventListener("load", onloadFunc, false);
} else if(this.attachEvent) {
this.attachEvent("onload", onloadFunc);
} else {
var onloadOld = this.onload;
this.onload = function() { onloadOld(); onloadFunc(); }
}
}
addOnload(function() { alert('FUNC'); });
//-->
</script>
</body>
Dadurch wird die Funktion dem onload Event hinzugefügt.
Die andere vorgehensweise setzt zwar ebenfalls das Onload-Event, diese wird aber durch die Angabe im BODY wieder überschrieben. So kommt diese Funktion nicht zur Ausführung.
mfg Manfred
Lesezeichen