JavScript Window outerHeight Property

The JavaScript Window outerHeight property is a read-only property that returns the height of the browser window, including any scrollbars, toolbars, and other window decorations.

Here are some examples of how the outerHeight property can be used in JavaScript code:

  1. To retrieve the height of the current browser window, you can use the following code:
var height = window.outerHeight;

// the value of height will be the height of the browser window
  1. To resize the current browser window to a specific height, you can use the following code:
window.resizeTo(window.outerWidth, 500);
  1. To center the current browser window on the screen, you can use the following code:
// get the screen width and height
var screenWidth = window.screen.availWidth;
var screenHeight = window.screen.availHeight;

// calculate the position of the window
var left = (screenWidth - window.outerWidth) / 2;
var top = (screenHeight - window.outerHeight) / 2;

// move the window to the calculated position
window.moveTo(left, top);

Overall, the outerHeight property provides a convenient way to retrieve and manipulate the height of the browser window. It can be used for tasks such as resizing the window, positioning it on the screen, or other operations that require the height of the window.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: