Check out the latest documentation.

Passing Properties To Client

An optional include script can be added to a web page to provide information to client side JavaScript concerning the device, enabling decisions to be taken client side. The  script  returned will create an object called FODF (51Degrees Features) which can be used to request properties. For example, the following JavaScript would return the IsMobile value.

										
										if
										
									 (FODF.IsMobile) {
  
										
										// Do something for mobiles only.
										
									
}

									

The value returned will be of a type associated with the property. See the Property Dictionary for details of property types.

The necessary javascript includes need to be added into the page by the developer. The following needs to be added to the HTML page header before accessing the FODF variable.

										
										<script 
										
										
										src=
										
										
										"/51Degrees.features.js.php"
										
										
										type=
										
										
										"text/javascript"
										
										
										></script>
										
									

Individual properties can be requested by specifing them in a query string. A script tag and an example of output are given below:

Tag:
										
										<script 
										
										
										src=
										
										
										"/51Degrees.features.js.php?IsMobile&BrowserName&BrowserVersion"
										
										
										type=
										
										
										"text/javascript"
										
										
										>
										
										
										</script>
										
									

 

Result:
										
										var
										
									 FODF 
										
										=
										
									 { IsMobile
										
										:
										
										
										false
										
									, BrowserName
										
										:
										
										
										"Chrome"
										
									, BrowserVersion
										
										:
										
										
										33
										
									 };