开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜