I have been trying to establish a responsive point in my mobile Webview by implementing the following JavaScript code:
var w = window.innerWidth-40;
var h = window.innerHeight-100;
So far, this solution has been working effectively. However, I noticed that the values -40 and -100 do not adjust according to the viewport scaling height and width.
When attempting to update the code as follows:
var w = window.innerWidth-40vw;
var h = window.innerHeight-100vh;
To ensure responsiveness and relative positioning within the viewport, using vw and vh units, the JavaScript stops functioning correctly. It seems that vw and vh units are only applicable in CSS. Is there a way to achieve this functionality purely in JavaScript?
Please refrain from suggesting JQuery solutions, as I am looking for a JavaScript-only approach!
Thank you