TOM: Scriptfehler - Object erwartet - warum?

Beitrag lesen

Hi

zuerst mal ein Tipp: Benutze zum debuggen Mozilla

dann das nächste:

Ich habe dein Script 1:1 benutzt und in folgende HTML-Seite eingefügt - geht doch!

Vielleicht gibts bei dir lay1 nicht?

<HTML>
<HEAD>
<TITLE>TEST</TITLE>
<script language="JavaScript">
function moveLayer()
{
 if(typeof(document.all) == 'object')
 {
 a = document.all.lay1.style.left;
 a = parseInt(a.substr(0,a.search('px')))+1;
 document.all.lay1.style.left = a+'px';
 if(a <= 500){window.setTimeout('moveLayer()',100);}
 }
 if(typeof(document.getElementById('lay1')) == 'object' &&
  typeof(document.all) != 'object')
 {
 a = document.getElementById('lay1').style.left;
 a = parseInt(a.substr(0,a.search('px')))+1;
 document.getElementById('lay1').style.left = a+'px';
 if(a <= 500){window.setTimeout('moveLayer()',100);}
 }
 if(typeof(document.lay1) == 'object')
 {
 document.lay1.left++;
 if(document.lay1.left <= 500){window.setTimeout('moveLayer()',100);}
 }
 if(typeof(window.opera) == 'object')
 {
 document.all.lay1.style.left++;
 if(document.all.lay1.style.left <= 500){window.setTimeout('moveLayer()',100);}
 }
}
</script>
</HEAD>
<BODY onload="moveLayer();">
<div id="lay1" style="position:absolute; top:30px; left:300px;">d</div>

</BODY>
</HTML>

Viel Spaß mit

MfG TOM

P.S.: Dann wird das Object wohl in einer anderen Funktion erwartet werden?