User Agent Detection

Goals

  • Identify device type

  • Identify browser type

  • Identify browser language

Use Cases

Language

Check all

// Some code
if (navigator.language.startsWith('fr')) {
    // Your script for French language users
    console.log("The script for French language users is running.");
    // Place your script here
}

Notes

https://www.tutorialspoint.com/detect-whether-a-device-is-ios-or-not-using-javascript

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent

https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent

Last updated