Sign in to edit and +1 items.
Login required
Download

Browser detection

(5)
Author(s) Kevin M. Gill, Edvinas Bartkus, Gennady Tsarik
Current Release 0.4   (1 month ago)
Grails Version 1.2.2 > *
Tags browser  user-agent 
Dependency
compile ":browser-detection:0.4"
Last updated by edvinasbartkus 2 years ago
grails install-plugin browser-detection
Last updated by gtsarik 1 month ago
This plugin provides service and tag library for browser detection. You can know what is the browser, version and operating system specified in request headers. The plugin is built on top of user-agent-utils library

To install:

grails install-plugin browser-detection

And then add code to your gsp's:

<browser:isMsie>Internet Explorer</browser:isMsie>

<browser:isSafari></browser:isSafari>

<browser:isChrome></browser:isChrome>

<browser:isFirefox></browser:isFirefox>

<browser:isOpera></browser:isOpera>

<browser:isiPhone></browser:isiPhone>

<browser:isiPad></browser:isiPad>

<browser:isWindows></browser:isWindows>

<browser:isMobile>Mobile phones or Android, iPhone, iPad, iPod, Blackberry, etc.</browser:isMobile>

<browser:isOther>browser is undefined or user-agent header is not set</browser:isOther>

You can use the following structure that emulates switch behavior:

<browser:choice>

<browser:isIE6></browser:isIE6>

<browser:isIE7></browser:isIE7>

<browser:otherwise></browser:otherwise>

</browser:choice>

Or the following:

<browser:isSafari versionGreater="5">
This text is rendered if Safari version is greater than 5.
For example, 5.0.1, 5.1
</browser:isSafari>

<browser:isFirefox version="3.*"> It works for all Firefox versions like 3.1, 3.6 and so on </browser:isFirefox>

<browser:isMsie versionLower="7">Internet Explorer 5.0, Internet Explorer 6.0</browser:isMsie>

At the moment wildcards are allowed only for version attribute. Be aware that 5.1 is greater than 5 and 5.0 equals to 5.

You can call methods isMsie, isSafari, isChrome and others with UserAgentIdentService service.

You can send suggestions to vare6gin(et)gmail.com

Last updated by admin 2 years ago
Last updated by admin 2 years ago