0

Using MVC 4.5 ...

I'm trying to prepare my website for retina screens.

How can I from codebehind (code on server) detect, if user has a Retina screen?

I would prefer not to do it from java, but from code on server.

dove
  • 20,469
  • 14
  • 82
  • 108
MojoDK
  • 4,410
  • 10
  • 42
  • 80
  • 2
    Java != JavaScript. BTW, You don't need to "detect a retina screen". You can use [media queries](http://webdesignerwall.com/tutorials/css3-media-queries) to support different style sheets for different resolutions. – Paolo Moretti Nov 22 '12 at 11:36

2 Answers2

0

Retina Display is a brand name and not tightly defined. It sounds like you want to detect whether it is a newer version of iPad or not. Details on detecting those are widespread.

dove
  • 20,469
  • 14
  • 82
  • 108
  • I need to figue out, if my... ... actually should be 80 pixels high or 160 pixels high to look good on retina screens (screens with double aspect ratio). – MojoDK Nov 22 '12 at 11:45
0

Try this:

(function(){
  if( document.cookie.indexOf('device_pixel_ratio') == -1
      && 'devicePixelRatio' in window
      && window.devicePixelRatio == 2 ){

    document.cookie = 'device_pixel_ratio=' + window.devicePixelRatio + ';';
    window.location.reload();
  }
})();
webdeveloper
  • 17,174
  • 3
  • 48
  • 47