I have written a small javascript code to get screen dimensions of the user browser. At first, the src attribute of an img element is set to a static image url. When the page is fully loaded, the following code, calculate screen dimensions and send them to the server by changing the src of the img that now contains the dimensions as uri parameters (Later, at server side, these parameters will be processed):
  <img id="screenres" src="http://static.example.com/image.jpg" alt="" width="20" height="20" />
  <script>
 window.onload=function(){
     var w =Math.round(screen.width);
     var h =Math.round(screen.height);
     document.getElementById("screenres").src=
                 "http://www.example.com/screen/"+w+"/"+h;
  }
  </script>
This approach works perfectly in desktop browsers, but for mobile users it fails. Could you please tell me what is wrong in this approach? Thank you beforehand for your suggestions to overcome this problem.
 
    