Detect a device is iOS or not using JavaScript Last Updated : 20 May, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report In order to detect a device whether it is iOS or not. We're going to Navigator platform and Navigator userAgent property. Navigator userAgent property This property returns the value of the user-agent header which is sent by the browser to the server. Returned value, have information about the name, version, and platform of browser. Syntax: navigator.userAgent Return value: It returns a string, denoting the user agent string for the current working browser. Navigator platform property This property returns the platform for which the browser is compiled. Syntax: navigator.platform Return value: It returns a string, representing platform of browser. Possible values. HP-UX Linux i686 Linux armv7l Mac68K MacPPC SunOS Win32 Etc. Example 1:This example detects the device by (navigator.userAgent) property and returns false. html <!DOCTYPE HTML> <html> <head> <title> JavaScript | Detecting a device is iOS. </title> </head> <body style="text-align:center;" id="body"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP" style="font-size: 15px; font-weight: bold;"> Detecting whether a device is iOS. </p> <button onclick="gfg_Run()"> detect </button> <p id="GFG_DOWN" style="color:green; font-size: 23px; font-weight: bold;"> </p> <script> var el_down = document.getElementById("GFG_DOWN"); function gfg_Run() { var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; el_down.innerHTML = iOS; } </script> </body> </html> Output: Before clicking on the button: After clicking on the button: Example 2: This example detects the device by (navigator.platform) property and returns true. html <!DOCTYPE HTML> <html> <head> <title> JavaScript | Detecting a device is iOS. </title> </head> <body style="text-align:center;" id="body"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP" style="font-size: 15px; font-weight: bold;"> Detecting whether a device is iOS. </p> <button onclick="gfg_Run()"> detect </button> <p id="GFG_DOWN" style="color:green; font-size: 23px; font-weight: bold;"> </p> <script> var el_down = document.getElementById("GFG_DOWN"); function gfg_Run() { var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); el_down.innerHTML = iOS; } </script> </body> </html> Output: Before clicking on the button: After clicking on the button: Example 3:This example detects the device by (navigator.platform) property and returns false. html <!DOCTYPE HTML> <html> <head> <title> JavaScript | Detecting a device is iOS. </title> </head> <body style="text-align:center;" id="body"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP" style="font-size: 15px; font-weight: bold;"> Detecting whether a device is iOS. </p> <button onclick="gfg_Run()"> detect </button> <p id="GFG_DOWN" style="color:green; font-size: 23px; font-weight: bold;"> </p> <script> var el_down = document.getElementById("GFG_DOWN"); function gfg_Run() { var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); el_down.innerHTML = iOS; } </script> </body> </html> Output: Before clicking on the button: After clicking on the button: Comment More infoAdvertise with us Next Article Detect a device is iOS or not using JavaScript P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to Detect the Device is an Android Device using JavaScript? Detecting an Android device using JavaScript helps improve web experiences. By checking the user agent string, developers can identify Android devices and apply specific features or styles. This method ensures compatibility and optimizes functionality for different platformsApproachUse the navigator 2 min read How to detect touch screen device using JavaScript? Sometimes you might be looking for some features to include into your web-app that should only be available to devices with a touch screen. You may need this detection while introducing newer smarter controls for touch screen users in the game app or a GPS and navigation application. While there are 3 min read How to detect flash is installed or not using JavaScript ? The task is to detect whether the user has installed Adobe Flash player or not with the help of JavaScript. we're going to discuss 2 techniques. Approach: Create a ShockwaveFlash.ShockwaveFlash object.If the instance's value is true, Flash is installed.If any error occurred, Use navigator.mimetypes 2 min read How to detect touch screen device using CSS ? In this article, we will learn how to detect touchscreen devices using CSS. In a website, it becomes important to detect the pointing device used by the user. For example, if the user uses a finger as the pointing device (which has less accuracy on the screen due to more screen-finger contact area) 2 min read How to detect the user's device using jQuery ? The task is to determine the user's device, whether it is iPad or not, using JQuery. Below are the required methods: Navigator userAgent Property: This property returns the value of the header of user-agent which is sent by the browser to the server. Returned value, have information like name, versi 1 min read Like