Background
I'm having trouble getting a reliable viewport size using JavaScript. I read this guide to configure the application and this guide to learn about targeting specific device permissions.
This is the tag <meta>on the page:
<!DOCTYPE html>
...
<meta name="viewport" content="target-densitydpi=device-dpi" />
This allows me to use the sharpest images to draw the interface. To check the resolution, I wrote this piece of code:
window.addEventListener('orientationchange', function() {
console.log(screen.availWidth + ' x ' + screen.availHeight)
}
Problem 1
I was hoping the actual available pixels could be calculated as:
width := screen.availWidth / devicePixelRatio
height := screen.availHeight / devicePixelRatio
But devicePixelRatiofixed in 3, regardless of the target dpi; so how can i determine the actual pixels at my disposal?
Problem 2
screen.availHeight , WebView.
:
console.log(document.documentElement.offsetHeight);
console.log(window.innerHeight);
, , , , dpi. ?