Javascript Detect iPhone device

<html>
    <head>
        <title>Mobile Detection</title>
        <script>
            function DetectIphone()
            {
               var uagent = navigator.userAgent.toLowerCase();
               if (uagent.search(“iphone”) > -1 || uagent.search(“ipod”) > -1 || uagent.search(“android”) > -1)
                  alert(‘true’);
               else
                   alert(‘false’);
            }
        </script>
    </head>
    <body>
        <input type=”button” OnClick=”DetectIphone()” value=”Am I an Iphone?” />
    </body>
</html>