How Liferay is identifying the browser and device


In this article we can know how liferay is identifying the browser and device.

Press Ctrl_Shift+J to see the elements. Look into the javascript it shows weather It is an Chrome or Firfox or IE or Iphone etc..





    Open the top_js.jspf file we have find the following snipetts.


    isChrome: function() {
return <%= BrowserSnifferUtil.isChrome(request) %>;
},
isFirefox: function() {
return <%= BrowserSnifferUtil.isFirefox(request) %>;
},
isGecko: function() {
return <%= BrowserSnifferUtil.isGecko(request) %>;
},
isIe: function() {
return <%= BrowserSnifferUtil.isIe(request) %>;
},
isIphone: function() {
return <%= BrowserSnifferUtil.isIphone(request) %>;
},

In JavaScript:

                   Browser:
                  Liferay.Browser.isIe()         // returns true or false
                  Liferay.Browser.isMozilla() // returns true or false

In VM file:

  In vm file we have predefined object to check

 #set ($isIE = $browserSniffer.isIe($request))
#set ($browserVer = $browserSniffer.getMajorVersion($request))

Here isIE variable contains true/false and browserVer returns version of the browser.

We can look into the BrowserSnifferUtil class , how it is identifying the devices , OS and browsers

  

Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Opening portlet in popup