How to get orientation of the device(ipad) in grails code
I want to get the orientation of the device (ipad or iphone). We can get the user agent by using request.getHeader("useragent")
in groovy code.
I need to get the orientation of the device i.e landscape or portrait mode in Groovy code. Can anyone help on this?
In general, the server does not know anything about the physical dimensions of the client's viewport. The request
hash merely gives you access to the HTTP headers included in the request. You would need to use Javascript to detect the size of the browser's window and make the appropriate changes on the client-side. In jQuery, you might begin with something like:
if($(window).width() > $(window).height()) {
// Viewport is landscape, do something
} else {
// Viewport is portrait, do something else
}
精彩评论