3

I've found window.innerWidth,window.innerHeight,body.clientWidth and body.clientHeight get different values when executing it before and after window.onload. However, the web page doesn't change at all(the areas are all the same). The test results are listed below.Is this the correct behavior for all web-kit based browsers?

<html>
<head lang="en">
   <meta charset="UTF-8">
<title></title>
</head>
<script>
     console.log(window.innerWidth);
     console.log("<br />");
     console.log(window.innerHeight);
     console.log("<br />");
     console.log(body.clientWidth);
     console.log("<br />");
     console.log(body.clientHeight);
</script>
<body>
<br/>===================================<br/> 
</body>
<script>
    console.log(window.innerWidth);
    console.log("<br />");
    console.log(window.innerHeight);
    console.log("<br />");
    console.log(body.clientWidth);
    console.log("<br />");
    console.log(body.clientHeight);
</script>
</html>

Test Results:
Android Phone(720*1280,4.7''),Android Chrome
360
567
964
176
===================================
980 - window.innerWidth changed
1544 - window.innerHeight changed
964
440 - Why body.clientHeight becomes 440 after the blank body is loaded.
nullox
  • 295
  • 2
  • 7
  • 18
  • 1
    On Android, 980px is default width for pages without specified viewport. It seems that after loading your page and not finding viewport metatag, it changes it to default width and height. – Alex Salauyou Aug 28 '14 at 06:40
  • So i will need to detect the window width and height and make manipulations after the body is loaded? – nullox Aug 28 '14 at 07:15
  • 1
    sure, since a browser cannot discover page dimensions before loading and rendering it... – Alex Salauyou Aug 28 '14 at 07:22

1 Answers1

0

I have facing similar problem to me the answer wat the target density of the device play a little with the device dencity meta tag. Url to similar problem but Is there any equivalent to Android's <meta name='viewport' content='target-densitydpi=device-dpi'> for Safari on the iPhone?

You can further investigate but i think there is the problem :)

Community
  • 1
  • 1