Peterle: per Javascript auf mehrere DIVs zugreifen

Beitrag lesen

Hallo nochmal!

Jetzt hab ich, denke ich, das eine problem gelöst, mit der eval-Lösung. Ich meine zwar, daß das auch ohne eval hätte gehen müssen, aber erstmal egal.

Jetzt scheints aber mit dem MouseEvent nicht mehr hinzuhauen.
Mensch, dabei hab ich nur versucht, die Layer-Geschichte rauszuwerfen, es muß ja auch mit DIV gehen und das kann ja der IE auch.
Aber .....

Vielleicht hat ja einer von Euch noch einen Tip.
Ich poste Euch hier mal den Javascript-Code und nochmal den HTML-Teil:

      • HTML - - -
        <DIV ID="trail6" STYLE="position:absolute; top:60px; left:60px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <DIV ID="trail5" STYLE="position:absolute; top:50px; left:50px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <DIV ID="trail4" STYLE="position:absolute; top:40px; left:40px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <DIV ID="trail3" STYLE="position:absolute; top:30px; left:30px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <DIV ID="trail2" STYLE="position:absolute; top:20px; left:20px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <DIV ID="trail1" STYLE="position:absolute; top:10px; left:10px; visibility:show;"><img src="trail1.gif" border="0" width=10 height=10></DIV>
        <SCRIPT LANGUAGE="JavaScript" SRC="mausspur.js"></SCRIPT>
      • End of HTML - - -
      • Javascript - - -
        ns4 = (document.layers)? true:false
        ie4 = (document.all)? true:false

if ( (ns4) (ie4) ) {

document.onmousemove = mouseMove
if (ns4) document.captureEvents(Event.MOUSEMOVE)

var XMouse = 50;
var YMouse = 50;
var imageArrayX;
var imageArrayY;

imageArrayX = new Array(0,0,0,0,0,0);
imageArrayY = new Array(0,0,0,0,0,0);
  
function MoveHandler(evnt) {
if ( (ns4) (ie4) ) {
  XMouse = evnt.pageX ;
  YMouse = evnt.pageY ;
}}

window.onMouseMove = MoveHandler;
}

function pushAndPop() {
                                                        
if ( (ns4) (ie4) ) {
  for (var ii=4;ii>=0;ii--)        
  {
     imageArrayX[ii+1] = imageArrayX[ii];
     imageArrayY[ii+1] = imageArrayY[ii];
  }
}
}

function drawCur() {              
if ( (ns4) (ie4) ) {

pushAndPop();                      
  
imageArrayX[0] = XMouse-15;        
imageArrayY[0] = YMouse-15;

for (var j = 0 ; j < 6 ; j++ ) {  
if (ns4) {
  netsi = "document.trail"+(j+1);
  obj = eval (netsi);
}
if (ie4) obj = trail[6-j].style;
obj.left =  imageArrayX[j];
obj.top =  imageArrayY[j];
  }
setTimeout("drawCur()", 5) ;        
}}

      • End of Javascript - - -