Search code examples
javascriptmobileoperating-systemgoogle-gadget

Detect Mobile Operating Systems via JavaScript


I'm developing a google gadget which needs to display one way if it is being viewed on a mobile/smartphone operating system (e.g. Android, iPhone, or any device that uses a mobile iGoogle page). But I only want it to display that way if the operating system is using mobile iGoogle.

I simply need JavaScript code to detect the operating system (if this can be done from within a google gadget). I've done a bit of research, but none of the codes are very simple.

Does anybody have ideas or suggestions?


Solution

  • You can find out what OS you are on by using the following:

    navigator.appVersion or navigator.userAgent