HTMLify
js2.html
Views: 599 | Author: demo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <!DOCTYPE html> <html> <head> <title>Vibration Button</title> </head> <body> <button id="vibrateButton"><h1>Vibrate</h2></button> <script> // Function to trigger vibration function vibratePhone() { if ("vibrate" in navigator) { // Vibrate for 1000 milliseconds (1 second) navigator.vibrate(1000); } else { console.log("Vibration API not supported"); } } // Attach the vibratePhone function to the button click event document.getElementById("vibrateButton").addEventListener("click", vibratePhone); </script> </body> </html> |