My Personal Wiki

La théorie, c'est quand on sait tout et que rien ne fonctionne.... La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi.

Outils pour utilisateurs

Outils du site


web:codding:javascript:img_souris

Une image qui suit la souris

__code javascript:__
 
  <!-- Script Image Souris  -->
  <script type="text/javascript">
 
                document.onmousemove = suitsouris;
                function suitsouris(evenement)
                {
                        if(navigator.appName=="Microsoft Internet Explorer")
                        {
                                var x = event.x+document.body.scrollLeft;
                                var y = event.y+document.body.scrollTop;
                        }
                        else
                        {
                                var x =  evenement.pageX;
                                var y =  evenement.pageY;
                        }
                        document.getElementById("image_suit_souris").style.left = (x+1)+'px';
                        document.getElementById("image_suit_souris").style.top  = (y+1)+'px';
                }
 
        </script>
  <!--Fin Script Image Souris  -->
  </head>
  <!--Code Image Souris  -->
  <img src="img/Frezzer.png" alt="Image qui suit la souris" id="image_suit_souris" style="position:absolute;display:block;z-index:5;" />
  <!-- Fin Code Image Souris  -->	

Bien penser à modifier le Path de l'image


sylvain 2020/02/02 13:03

web/codding/javascript/img_souris.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki