screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Operating System Information</title> </head> <body> <h1>Operating System Information</h1> <p id="os-info">Click the button to get OS information.</p> <button id="os-button">Get OS Information</button> <script> // JavaScript code to retrieve operating system information function getOperatingSystem() { const platform = navigator.platform; if (platform.indexOf('Mac') !== -1) return 'Mac OS'; if (platform.indexOf('Win') !== -1) return 'Windows'; if (platform.indexOf('Linux') !== -1) return 'Linux'; if (platform.indexOf("X11") != -1) os = "UNIX"; return 'Unknown'; // Default to 'Unknown' if the platform is not recognized } // Function to display OS information function displayOSInformation() { const osInfoElement = document.getElementById('os-info'); osInfoElement.textContent = "Operating System: " + getOperatingSystem(); } // Event listener for the button click document.getElementById('os-button').addEventListener('click', displayOSInformation); </script> </body> </html>