How do I get the size of the browser window using Prototype.js version 1.6.0.3?
Use window. innerWidth and window. innerHeight to get the current screen size of a page.
If you need to obtain the width of the window minus the scrollbar and borders, use the root <html> element's clientWidth property instead. The innerWidth property is available on any window or object that behaves like a window, such as a frame or tab.
You can use the window. innerHeight property to get the viewport height, and the window. innerWidth to get its width. let viewportHeight = window.
Definition and Usage The innerWidth property returns the width of a window's content area.
According to the Prototype API documentation:
var viewport = document.viewport.getDimensions(); // Gets the viewport as an object literal
var width = viewport.width; // Usable window width
var height = viewport.height; // Usable window height
And the same idea but more compact:
var WindowSize = Class.create({
width: window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth),
height: window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight)
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With