Datenschutzerklärung

mausschreiber hinter div

Validome - Forum

Startseite Validome
RSS 2.0  
Sie sind nicht angemeldet. Atom 1.0  
Forum Home / Javascript-Forum /

mausschreiber hinter div

  Beitrag schreiben
Autor
Beitrag Seiten: 1
inesmm
Mitglied

Registriert: 11.09.2006
Beiträge: 5
hallo,
und zwar habe ich hier folgenden code:

<html>
<head>
<title>Mausschreiber</title>

<script language="JavaScript">


        if(document.getElementById&&document.styleSheets) {
                standby=0;
                p=0;

                document.write("<style type='text/css'>div.maus{position:absolute;right:-100px;top:-100px;font-size:80%;color:#000000}</style>");
                (document.all)?max=1000:max=1000;

                for(i=0;i<max;i++) document.write("<div class='maus' id='P"+i+"'>°</div>");

                document.onmousedown=checkStatus;
                document.onmousemove=setPoint;
            }

            function checkStatus(e) {

                ((document.all&&standby==0&&event.button==1)||(!document.all&&standby==0&&e.which==1))?standby=1:standby=0;
            }

            function setPoint(e) 
      {
                if(document.all&&standby==1) {
                    document.getElementById("P"+p).style.left=event.x+document.body.scrollLeft-20;
                    document.getElementById("P"+p).style.top=event.y+document.body.scrollTop-20;
                }
                else if(standby==1) {
                    document.getElementById("P"+p).style.left=e.pageX-20;
                    document.getElementById("P"+p).style.top=e.pageY-20;
                }
                (p<max-1)?p++:p=0;
                }


</script>

</head>

<body>



</body>
</html>

Das ist also eine Art Mausschreiber, bei Click auf die Maus malt die Maus folgend der Bewegung, bei erneutem Click hört sie damit aus.
Das Problem ist nur, sobal ich eine farbige div hinlege, malt die Maus nicht mehr darüber sondern darunter.
Weiss jemand wie man das ändern kann? Wäre für Hilfe sehr dankbar.


03.10.2006 12:11:27
  Zitieren
HTMELL
Administrator

Registriert: 11.05.2006
Beiträge: 544
Hallo,

Code:

<html>
  <head>
    <title>Mausschreiber</title>
    
    <style type='text/css'>
      div.maus  { position:absolute; right:-100px; top:-100px; font-size:80%; color:#000000; }
      #main     { background-color:#ff0000; width:800px; height:600px; }
    </style>
  </head>

<body>
  <div id="main"></div>
  
  <script language="JavaScript">
    if(document.getElementById && document.styleSheets) {
      standby = 0;
      p = 0;
      max = 1000;
  
      var div = document.createElement("div");
      div.className = "maus";
      div.appendChild(document.createTextNode('°'));
      
      for(i=0; i<max; i++) {
        var tmp = div.cloneNode(true);
        tmp.id = "P" + i;
        document.getElementById("main").appendChild(tmp);
      }
      document.getElementById("main").onmousedown = checkStatus;
      document.getElementById("main").onmousemove = setPoint;
    }

    function checkStatus(e) {
      ((document.all && standby==0 && event.button==1)||(!document.all && standby==0 && e.which==1)) ? standby=1 : standby=0;
    }

    function setPoint(e) {
      if(document.all&&standby==1) {
        document.getElementById("P"+p).style.left=event.x+document.body.scrollLeft-20;
        document.getElementById("P"+p).style.top=event.y+document.body.scrollTop-20;
      }
      else if(standby==1) {
        document.getElementById("P"+p).style.left=e.pageX-20;
        document.getElementById("P"+p).style.top=e.pageY-20;
      }
      (p < max-1) ? p++ : p=0;
    }
  </script>
</body>
</html>



_______________________________________
mfg
Thomas Mell

www.validome.org

03.10.2006 15:13:27
  Zitieren
Seiten: 1   Beitrag schreiben
Wechsel zu

Die letzten Beiträge aus diesen Forum

Valid HTML 4.01