

If you want to resize a window so that it’s small enough to fit a user’s display area, make your window smaller than the display area.

If you create a window and resize it to 800 pixels wide, people with screens narrower lower than 800 pixels must scroll to view the window. Name – Specifics the name you’d like to call the window you createĭifferent users may view your Web pages using different browser resolutions. _parent – Content loads in the page’s parent frame if one exists _self – Content replaces the content in the current page _top – Content replaces framesets that may exist in the current page When you leave it that parameter blank or give it a value of “_blank,” JavaScript creates a new window. The second parameter controls how JavaScript opens a new window. Those values are 300 and 200 in this example. The final two optional parameters enable you to set the new window’s width and height in pixels. Leave this parameter blank if you’d like to open an empty window. This example opens an HTML page named M圜reatedWindow.html. The first parameter contains the URL you wish to open in the new window. That variable is important because you need it to manipulate the new window.

That variable holds a reference to your new popup window. The following code creates and opens a new popup browser window that you can control: window1 = window.open("M圜reatedWindow.html", "", "width=300, height=200") For instance, you might want site visitors to view a small popup that shows a map or table. While some sites open popups that display advertising, others use popups to display helpful information. A popup is simply a browser window that opens while you’re viewing another browser window. Popup blockers are so popular these days that many browsers build them right into their infrastructure. New to JavaScript? Visit Udemy to learn pro coding tips.

However, you can use built-in JavaScript functions to resize and reposition browser windows instantly. Imagine the chaos that could ensue if any random function could shrink your browser window to the size of a quarter. Fortunately, you cannot move or resize a browser window your JavaScript code did not create.
