basti1012.bplaced.net

Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
    Ich will mit Javascript erreichen das nach 5 Sekunden die Maus versteckt wird.

    Code

                                        
                                    
    <script src="/js_webseite/jquery.js"></script>
    <style>
      body{
      height:100vh;
      width:100vw;
      font-size:100px;
    }
    </style>
    <body>
      Inhalt
      <div id="hint"></div>
      </body>
    <script>
      var sekunden=5;
    var timer, status=0;
    var x1=0, x2=0, y1=0, y2=0;
    bod=document.getElementsByTagName('body')[0];
    hinweiss=document.getElementById('hint');
    bod.addEventListener('mousemove',function(event){
            if(x1==0 && y1==0) {
              x1=event.screenX;
              y1=event.screenY;
              setTimeout('x1=0; y1=0',40);
            }
            x2=event.screenX;
            y2=event.screenY;
            setTimeout('x2=0; y2=0',40);
            if(x1 != x2 || y1 != y2) timerStart();
    });
    function timerCheck() {
            if(status==1) {
              timer-=1;
              if(timer>0) {
                setTimeout('timerCheck()',1000);
                    bod.style.cursor='default';
                    hinweiss.innerHTML='Maus verschwindet in '+timer+' Sekunden'; 
              }else{
                    bod.style.cursor='none';
                    status=0;
                    hinweiss.innerHTML='';
              }
            }
    }
    function timerStart() {
            timer=sekunden;
            if(status==0) {
              status=1;
              timerCheck();
            }
    }
    </script>