0

What is the best way to know which device type is requesting website?

I want to know that which device (desktop/laptop/mobile/tablet etc..) is generating request to my website using java script/j-query or c# code.

Also i want to know few more details:

Device screen resolution OS Name Browser Name and Version Requesting IP address Device ID Location

Is there any way to get all the above details...pls suggest.

Romesh Somani
  • 363
  • 3
  • 4
  • 18
  • This is defiantly an interesting question though! For some people it would work better to do this with a WYSIWYG editor. Most modern editors can do this right in the program its self. – pattyd May 28 '13 at 13:53
  • 1
    @pattyd it can be interesting, but it is not more or less interesting than the other questions that have been asked about this very subject. There's really no use for answers repeating what has been said before, we better consolidate all knowledge in a single question. That's what the Close as Duplicate function is for. – CodeCaster May 28 '13 at 14:02
  • @CodeCaster Yes, I agree with you. I also flagged it... – pattyd May 28 '13 at 17:07
  • Are you going to accept an answer? – pattyd Jul 01 '13 at 16:37

3 Answers3

2

The WURFL project was started for exactly this purpose. It parses the client-provided User-Agent string into a list of capabilities, input methods, device types and the like. There are APIs for all common serverside languages, and it provides tons of properties.

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136
1

Using request header fields you can find who us accessing...

for ex :

if(request.getHeader("User-Agent").indexOf("Mobile") != -1) {

}

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
1

You can use this JavaScript code (found here) to get some info on the user's screen.
Then, you could set up a condition to check if the screen size is the size of a tablet, phone, computer, etc...

<script>
document.write("Total width/height: ");
document.write(screen.width + "*" + screen.height);
document.write("<br>");
document.write("Available width/height: ");
document.write(screen.availWidth + "*" + screen.availHeight);
document.write("<br>");
document.write("Color depth: ");
document.write(screen.colorDepth);
document.write("<br>");
document.write("Color resolution: ");
document.write(screen.pixelDepth);
</script>

As for the OS, i am not sure at this time. If i find any more information i will edit this answer. I hope this helps!

pattyd
  • 5,927
  • 11
  • 38
  • 57