Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Know the Client  RSS feed

 
Skanth Chang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How the server know the device type from which request came from. I have requirement to implement the logic based on the type of the device. Eg: Mobile, TAB, PC or Laptop. Is there any existing API in Jquery to know the details about the client?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, JQuery doesn't run on the server so maybe that isn't the best way to ask the question. On your server you get all kinds of information about the sender in the HTTP headers, but that would be in your servlet. So I'm going to move this to the Servlets forum.

I don't expect you can distinguish between a PC and a laptop because a laptop IS a PC.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to know? Depending upon what you are trying to do, you may not need to know what the device is, but rather what the capabilities are.

For example, if screen size is what you need to know for CSS, then media queries would be used rather than device detection.

We need to know what you are trying to accomplish before putting forward any recommendations.
 
Junilu Lacar
Sheriff
Posts: 10879
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Skanth Chang wrote:Is there any existing API in Jquery to know the details about the client?

Sounds like you're barking up the wrong tree with this. I wouldn't try to start from the JQuery end. If anything, you should start with logic running on the server side, like detecting the user agent that made the request. Then you can control the rendering of the response and setting up the page so JQuery can do something accordingly on the client side. But as Bear said, you should explain what you're trying to do in more detail so you get the right recommendations.
 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's simply the acreage of screen you have to work with that you need to know for layout purposes, then you might want to look at something like Bootstrap for your client code.
There are others, but that's the one I have in front of me.

If it's more complex than that then you'd need some other solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!