Exécuter
❯
Exécuter le code
Ctrl+Alt+R
Enregistrer le code
Ctrl+Alt+A
Changer d'orientation
Ctrl+Alt+O
Changer de thème
Ctrl+Alt+D
<!DOCTYPE html> <html> <body onhashchange="myFunction()"> <p>Cliquez sur le bouton pour changer la partie d'ancre de l'URL actuelle en #part5</p> <button onclick="changePart()">Essayez-le</button> <p id="demo"></p> <script> // Utiliser la propriété location.hash pour changer la partie ancre function changePart() { location.hash = "part5"; let x = "La partie d'ancre est maintenant : " + location.hash; document.getElementById("demo").innerHTML = x; } // Alerter un texte si des modifications ont été apportées à la partie d'ancrage function myFunction() { alert("La partie d'ancre a changé !"); } </script> </body> </html>