Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]2292[/thread]

JavaScript: <div> der Maus folgen lassen: Anfängerfrage



<< >> 1 Eintrag, 1 Seite
Matze
 2006-04-01 13:53
#24755 #24755
User since
2005-08-29
222 Artikel
BenutzerIn
[Homepage] [default_avatar]
Hallo!

Ich habe mich ein wenig im Internet über JavaScript informiert und hab mal versucht ein <div>-Tag der Maus folgen zulassen.

Es ist im Moment nur für IE 5+.

Jetzt gibt es allerdings ein Problem:
Wenn ich den <div>-Tag nicht im HTML Dokument sondern im JavaScript mit document.write() schreibe dann funktioniert das mit dem Maus folgen nicht mehr.

Hier das HTML-Dokument:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
<html>
<head>
 <title>Meine eigenen Info Boxen</title>
 <script type="text/javascript" src="info.js"></script>
</head>
<body bgcolor="#bbddbb"
      onLoad='InfoText("Hallo du sonnige Welt!");'
      onMouseMove="MouseMove(event);">
</body>
</html>


Und info.js:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var xplus=0,yplus=-10;
var runnerobject;

function MouseAction(mausx,mausy) {
 runnerobject.left=mausx+xplus;
 runnerobject.top=mausy+yplus;
}

function MouseMove(event) {
 var mausx,mausy;

 if (typeof(event) != "object") {
   return;
 }

 mausx=event.clientX;
 mausy=event.clientY;

 if (document.body.scrollLeft) {
   mausx += document.body.scrollLeft;
 }
 if (document.body.scrollTop) {
   mausy += document.body.scrollTop;
 }

 MouseAction(mausx,mausy);
}

function MouseInit() {
 window.onmousemove = MouseMove;
 runnerobject = document.all.runner.style;
}

function InfoText(text) {
 document.write("<div id='runner' style='position:absolute;top:;left:;background:#ff99cc;margin:10pt;padding:10pt;'>"+
 "<span'>"+text+"</span></div>");

 MouseInit();
}


Ich hoffe auf eure Hilfe!

MfG. Matze
Mit freundlichen Grüßen: Matze
<< >> 1 Eintrag, 1 Seite



View all threads created 2006-04-01 13:53.