Detect device

2 posts, 0 answers
  1. Henry
    Henry avatar
    44 posts
    Member since:
    Feb 2013

    Posted 31 Oct 2013 Link to this post

    Hi Experts,

    From client code, is it possible to check if my web page containing radcontrols are viewed in a handheld device such as IPAD, smartphones? If its a handheld device, I want to show the user a page optimized for mobile view.

    Thanks
    Henry
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 Oct 2013 Link to this post

    Hi Henry,

    It is possible by checking the user agent. You can try the following client side code which works fine.

    JavaScript:
    <script type="text/javascript">
        function pageLoad() {
            if ($telerik.isMobileSafari) {
                //Page Viewed in iPhone OS Mobile Safari
            }
            else if ($telerik.isTouchDevice) {
                //Page viewed in a  device that supports touch capabilities such as IPAD, tablets, other smartphones.
            }
            else {
                //Your Code.
            }
        }
    </script>

    Thanks,
    Princy.
Back to Top