Other Window Methods
Window Methods | Descriptions |
---|---|
window.open() | This method is used to open a new tab or window with the specified URL and name. |
window.close() | This method is used for closing a certain window or tab of the browser that was previously opened by the window.open( ) method. |
window.moveTo() | This method is used in the window to move the window from the left and top coordinates. |
window.resizeTo() | This method is used to resize a window to the specified width and height |
Example: Implementation to show current window size.
HTML
<!DOCTYPE html> < html > < head > < style > h1 { color: green; } </ style > </ head > < body > < h1 >w3wiki</ h1 > < p id = "geeks" ></ p > < script > document.getElementById("geeks").innerHTML = "Browser inner window width: " + window.innerWidth + "px< br >" + "Browser inner window height: " + window.innerHeight + "px"; </ script > </ body > </ html > |
Output:
Browser Object Model
Browser Object Model (BOM) is a programming interface JavaScript tool for working with web browsers. This enables access & manipulation of the browser window, frames, and other browser-related objects by facilitating the JavaScript code.
The main object is “window,” which helps to interact with the browser. By default, you can call window functions directly.
window.alert(" Hey Geeks");
// Same as
alert(" Hey Geeks ");
Note: It is not recommended always to explicitly mention “window” because it’s the default. So, the alert(” Hey Geeks “); is equivalent to the longer version.