screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue js Get Operating System Version </h3> Operating System: {{ os }} </div> <script type="module"> const app = new Vue({ el: "#app", computed: { os() { if (typeof navigator === "undefined") { return "Unknown OS (no navigator object)"; } let userAgent = navigator.userAgent; if (userAgent.indexOf("Windows") !== -1) { return this.getWindowsOS(userAgent); } else if (userAgent.indexOf("Macintosh") !== -1) { return "Mac OS X"; } else if (userAgent.indexOf("Linux") !== -1) { return "Linux"; } else if (userAgent.indexOf("iPhone") !== -1) { return "iPhone OS"; } else if (userAgent.indexOf("iPad") !== -1) { return "iPad OS"; } else if (userAgent.indexOf("Android") !== -1) { return "Android OS"; } else { return "Unknown OS"; } }, }, methods: { getWindowsOS(userAgent) { if (userAgent.indexOf("Windows NT 10.") !== -1) { return "Windows 10"; } else if (userAgent.indexOf("Windows NT 6.3") !== -1) { return "Windows 8.1"; } else if (userAgent.indexOf("Windows NT 6.2") !== -1) { return "Windows 8"; } else if (userAgent.indexOf("Windows NT 6.1") !== -1) { return "Windows 7"; } else if (userAgent.indexOf("Windows NT 6.0") !== -1) { return "Windows Vista"; } else if (userAgent.indexOf("Windows NT 5.2") !== -1) { return "Windows Server 2003; Windows XP x64 Edition"; } else if (userAgent.indexOf("Windows NT 5.1") !== -1) { return "Windows XP"; } else if (userAgent.indexOf("Windows NT 5.01") !== -1) { return "Windows 2000, Service Pack 1 (SP1)"; } else if (userAgent.indexOf("Windows NT 5.0") !== -1) { return "Windows 2000"; } else if (userAgent.indexOf("Windows NT 4.0") !== -1) { return "Windows NT 4.0"; } else if (userAgent.indexOf("Windows 98; Win 9x 4.90") !== -1) { return "Windows Millennium Edition (Windows Me)"; } else if (userAgent.indexOf("Windows 98") !== -1) { return "Windows 98"; } else if (userAgent.indexOf("Windows 95") !== -1) { return "Windows 95"; } else if (userAgent.indexOf("Windows CE") !== -1) { return "Windows CE"; } else { return "Unknown Windows version"; } }, }, }); </script> </body> </html>