Check out the latest documentation.

Client Side Overrides

 

Sometimes, the User-Agent alone does not contain enough information for certain properties. For example:

  • The User-Agent of an iPhone does not provide sufficient information to determine the particular iPhone model: 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.

When used 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. .

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

Support for Client Side Overrides is API dependent. Future releases will include this functionality for unsupported APIs.

Using Client Side Overrides

Configuration

Important:  When using NuGet packages, the below will be added to the modules section in your web.config file. If you are not using NuGet to integrate 51Degrees into your project then please add the following to your web.config file:

									
<configuration>
    <system.webServer>
        <modules>
            <!-- IIS 7.X - Registers 51Degrees Detector Module. Without this call to 51Degrees.core.js won't work.-->
            <remove name="Detector"/>
            <add name="Detector" type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"/>
        </modules>
    </system.webServer>
</configuration>


									

Example

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>