Screen Width Problem when using different browsers on handheld / smart devices

I created a script in which I discover a mobile browser, and when its true JS function getwidthis called and redirects the visitor to a specific URL across the width of the screen of my device. I used the basic js ie detection method screen.widthto determine the screen width

The problem I am facing is that different browsers return different screen widths. As I have a tablet (Android 4.0.3) whose actual screen width is 800 PX, and when I run my script on the default browser on it, it returns the exact screen width 800px, but when I open it with different browsers, then they return different widths, for example, UC Browser returns 740 PX ( ISSUE 2: also when onload function i tried to return screen width on UC browser then it returns screen width as 0px and after page load when i call the same function again then it returns width=740px) when I run the script in Opera Mini, then it returns the width as 441 PX.

Please tell me what is the most efficient way to determine the screen width of Hand Held / Smart Devices. So I can do the redirection perfectly based on the width of the screen.

URL to TEST: http://radiations3.aiksite.com/home.html

Thank,

+5
2

, , Javascript, CSS. -? - , .

, , ( ), ( ):

var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;

, , x y, . , , , - , , , CSS. , Javascript .

+8

jQuery

$(window).width();
$(window).height();

.

+1

All Articles