Detect if a smartphone is being used

.smartCheck()


Description: Detect if the user is using a smartphone to browse your website using JavaScript mobile device detection.


Example:

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>smartCheck demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
        
        <div class="result"></div>
        
        <script>
            
            bitsyCode.ready(function(){
                var isSmart = bitsyCode.smartCheck();
                
                if (isSmart.detected) {
                    bitsyCode(".result").html("<b>Detected:</b> Smartphone detected.<br /><b>Browser:</b> " + isSmart.browser);
                } else {
                    bitsyCode(".result").html("Smartphone NOT detected.");
                }
            })
            
        </script>
     
    </body>
    </html>

Preview:

  • Usage

    • How to use:

      "smartCheck" does a simple detection to check if a smartphone is being used to view your page.

    • USAGE:

      bitsyCode.smartCheck();
      bitsyCode.smartCheck({ device: "android" });
  • Options

    • What options are there:
      device: '' (default value)
      // Specify which smartphone device you are checking for, else by default it will check if any smartphone is being used.
    • Device options, list of browser agents to detect against:
      device: 'android' // Detect if an Android browser smartphone is used.
      device: 'blackberry' // Detect if an BLACKBERRY browser is used.
      device: 'ios' // Detect if an IOS browser smartphone is used.
      device: 'nokia' // Detect if an Nokia browser is used.
      device: 'opera' // Detect if an Opera Mini browser is used.
      device: 'windows' // Detect if an WINDOWS browser is used.
      device: 'webOS' // Detect if an webOS browser is used.
      device: 'Zune' // Detect if an Zune browser is used.
  • Returns

    • Returns
      Returns:
          object {
              detected: (true or false), // Returns true if smartphone detected, else false is returned.
              browser: '' // Returns the browser name eg. Android, IOS
          }
Share