
We’ve updated the screenWidth inside the method. Whenever we resize the window, this method will be called. In this method, we attach an event listener to the resize event. We then call the onScreenResize method immediately after it. As soon as the app is mounted, we update its value from the window object using window.innerWidth. In the above code we’ve taken a reactive state named screenWidth with a default value of 0. Its possible get the same behavior as when I resize the window vertically, even horizontally How can I edit my code to get it var camera, scene. We can easily do that by attaching an event listener to the resize event in our Vue app as follows: Screen width: Code language: HTML, XML ( xml ) Please check out the tutorial on JavaScript event listeners to learn more about it.We may sometimes need to know the screen width (viewport) of the application. You should better assign a new event handler to the resize event using event listener, as shown in the example above. You should avoid using the solution like window.onresize = function(event), since it overrides the window.onresize event handler function. Note: Please resize the browser window to see how it works. Calling the function for the first time Window.addEventListener("resize", displayWindowSize) Before ResizeObserver, you had to attach a listener to the document's resize event to get notified of any change of the viewport's. Available in: English, Espaol, Portugus,, ,, and. ResizeObserver lets you know when an element's size changes. Microsoft makes no warranties, express or implied, with respect to the information provided here. ResizeObserver: it’s like document.onresize for elements. Attaching the event listener function to window's resize event Some information relates to prerelease product that may be substantially modified before it’s released. Var h = ĭocument.getElementById("result").innerHTML = "Width: " + w + ", " + "Height: " + h

Get width and height of the window excluding scrollbars
