• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

Client Side Overrides

When use with the Enterprise version of the data set the API can augment static data about devices with dynamic information determined by interrogating the device using javascript to determine additional information. Examples include:

  • The User-Agent of an iPhone does not provide sufficient information to determine the model of iPhone. This is a deliberate choice Apple have made. However javascript running in an iPhone browser can be used to determine the screen size and therefore the numeric model version.
  • The device may be used in Landscape or Portrait orientation which is not a static feature of the device.

Feature detection when enabled enhances properties in the 51Degrees dictionary to provider additional details. Once enabled properties such as HardwareModel or Orientation will become more accurate or populated.

Important: Before invoking the FODPO() javascript object on the client side, a check must be carried out on the server for the presence of values in JavascriptHardwareProfile as shown in the snippet below:

namespace Detector
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Browser["JavascriptHardwareProfile"] != null)
                test_label.Text = "<script src=\"/51Degrees.core.js\" type=\"text/javascript\"></script>" + "<script type=\"text/javascript\"> new FODPO();</script>";
            else
                test_label.Text = "";
        }
    }
}

ASP Developers

When used with ASP.NET the previous examples work unaltered. The necessary javascript includes are inserted automatically into the page.

MVC

The necessary javascript includes and script need to be added into the page by the developer. The following needs to be added to the header of the view:

<script src="/51Degrees.core.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
new FODPO();
//]]>
</script>

Need Help?