Tuesday, 6 May 2014

Tridion Client-Side Device Detection

The SDL Tridion Context Engine gives you contextual information that you can use to optimise your web experience for different devices - in other words tweak and tune your web site for mobile.

In my previous blog post, I gave a quick overview of our context repository and mentioned that the context repository can give us device properties like screen width and height.

However, if you really want to know width and height of the users’ device or browser - then we are often better off discovering it directly from the browser.
The user might zoom in or out, they might rotate the screen or they might use a different screen.

The SDL Tridion documentation covers deploying the discovery resolver, in which it says you can add the following to your page:

    <script type="text/javascript" src="js/discover-min.js"></script>

This JavaScript file simply discovers a collection of device properties, such as width, height and pixel ratio and uses these over and above those defined in the repository. As with any other context properties these are placed in the Tridion claim store, ready for your use.