force window resize javascript Code Example

Some methods of resizing windows

  • “F11” toggles in/out of Full Screen mode, make sure you are not in Full Screen mode when trying to resize a window
  • Drag the edges of the window to resize.
  • Drag window by title bar to move. Firefox 29 dropped title bar, the option to restore is found at the bottom of the Toolbar customization dialog.
  • On Windows use “Alt+SpaceBar” to move and resize window, especially if the title bar is not accessible because the window is too high. Move allows you move window. Size (resize) allows you to resize in a vertical or a horizontal direction but not at the same time. You can use the mouse or the cursor keys with move or size.  Use “Enter” to release the grasp after dragging window or edges.
  • (Windows 7) use WinKey+right-cursor-key to move Window to right side of screen — works across multiple monitors, and window can be resized afterwards by moving edges of the window. May also be used if Window gets lost on a monitor no longer connected — use shortcut until window appears in position on current screen.
  • (Windows) “Alt+SpaceBar” > “M” (Move)
  • (Windows) use left and right cursor keys to move window left or right, use “Esc” to end
  • (Mac:) see “How to resize a window on your Mac’s screen that’s too big to drag” (MacYourself)

If after following these steps to resize windows, new Firefox windows still start up too big, you may have a corrupt localstore.rdf.



Post navigation

Previous Previous post: Vivaldi got bookmark icons and multiple instance support

Next Next post: How to move a window using keyboard only in Windows 10 and other versions


This function resizes the window so that it takes up one quarter of the available screen. See the Screen.availWidth and Screen.availHeight properties.

function quarter() { window.resizeTo( window.screen.availWidth / 2, window.screen.availHeight / 2 ); }

Handle Resize Events

When a browser does something, JavaScript often knows about it. For instance, if you resize your browser window manually, JavaScript can alert you to that event. You’ll need to set up an event handler to do that, as shown below:

This code tells JavaScript to execute the code within the function whenever a window resizes. Replace the alert statement with the code you’d like to run when a resize event occurs. This example adds an onresize event to the window1 popup window described in previous examples. However, you can also add this event to your main window using the following code:

Custom resize in Windows

When the upper-right section of the window looks like mouse cursor, your window is now in "resize mode," meaning you can use the mouse cursor to make the window any size you want. To do so, move the cursor to any edge or corner of the window until a double-headed arrow appears. When this arrow appears, click-and-drag to make the window larger or smaller. If this double-headed arrow does not appear, the window cannot be resized.

The animation below shows a double-headed arrow on the bottom, left, and corner of a window and how it resizes a window. To make the window horizontally bigger, move the cursor to the left or right edge of the window until it changes to the double-headed arrow. To make the window vertically bigger, do the same thing at the top or bottom of the window. To resize horizontally and vertically at the same time, use one of the corners of the window.

How to resize a window using Windows menus

A window can be resized using a series of keyboard shortcuts. Below are the steps for resizing a window only using the keyboard.

  1. Press Alt+Spacebar to open the window’s menu.
  2. If the window is maximized, arrow down to Restore and press Enter.
  3. Press Alt+Spacebar again to open the window menu, arrow down to Size, and press Enter.
  4. Press the up or down arrow key if you want to resize the window vertically or the left or right arrow key if you want to resize horizontally.
  5. Once an arrow key is pressed, you can press the same or opposite arrow key to continue resizing the window.

Empower your team. Lead the industry

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo


Leave a Reply

Your email address will not be published.