window Acts as a global scope and represents a browser window
window.innerWidth Gets the internal width of the browser window. Internal width and height refers to the width and height used to display a web page after removing placeholder elements such as menu bar, toolbar and border.
window.innerHeight Gets the internal height of the browser window
window.outerWidth Gets the full width of the browser window
window.outerHeight Gets the entire height of the browser window
Window. The close () Close the window
Window. The alert () A system message box with an OK button pops up, displaying the specified text
window.confirm(“Are you sure?” ) A query dialog box with OK and Cancel buttons pops up, returning a Boolean value
window.prompt(“What’s your name?” , “Default”) Prompts the user for input, accepts two parameters, the text to be displayed to the user and the default value in the text box, and returns the value in the text box as a function value
window.defaultStatus Default status bar information that changes text until the user leaves the current page
window.open() Open a new browser window or find a named window
window.print() Prints the contents of the current window
window.focus() Get focus
window.blur() Move the focus
window.moveBy() Moves a window by a specified pixel relative to its current coordinates
window.moveTo() Moves the upper left corner of the window to a specified coordinate
window.resizeBy() Resize the window to the specified pixel
window.resizeTo() Resize the window to the specified width and height
window.scrollBy() Scrolls the content at the specified pixel value
window.scrollTo() Scrolls the content to the specified coordinates
window.setTimeout() Sets the specified code to execute after the specified number of milliseconds, taking 2 arguments, the code to execute, and the number of milliseconds to wait
window.clearTimeout(“”) Unset setTimeout()
window.setInterval(); Repeats the specified code an infinite number of times at specified intervals
Window. ClearInterval (” “) Unset setInterval()
window.history.go(-1) History of access to the browser window. Negative numbers are backward and positive numbers are forward
window.history.back() Returns the previous URL
window.history.forward() Returns the next URL
window.history.length You can view the number of pages in history

Note that the navigator information can be easily modified by the user, so the values read by JavaScript are not necessarily correct

navigator Represents browser information
navigator.appName Browser name
navigator.appVersion Browser Version
navigator.language The language of the browser Settings
navigator.platform Operating System Type
navigator.userAgent User-agent character string set by the browser
navigator.cookieEnabled Returns true if cookie is enabled, false otherwise
navigator.plugins Array of plug-ins installed in the browser

Judge browser don’t use the if/else it is difficult to maintain, use | |

Var width; if (getIEVersion(navigator.userAgent) < 9) { width = document.body.clientWidth; } else { width = window.innerWidth; }Copy the code
var width = window.innerWidth || document.body.clientWidth;
Copy the code
screen Represents screen information, which can also be referenced as window.screen
screen.width Screen width is measured in pixels
screen.height Screen height is measured in pixels
screen.colorDepth Returns the color number, such as 8, 16, 24
screen.availWidt The width of the screen a window can use is measured in pixels
screen.availHeight The height of the screen that a window can use is measured in pixels
location Represents the URL information of the current page
location.href The full URL of the currently loaded page
location.portocol The protocol used in a URL, the part before the double slash, such as HTTP
location.host The server name, for example, www.wrox.com
location.hostname Usually equal to host, sometimes omitting the preceding WWW
location.port The URL declares the requested port. By default, most urls have no port information, such as 8080
location.pathname / the part of the URL after the host name, such as /pictures/index.htm
location.search The part of the URL that executes the GET request after the question mark, also known as the query string, such as? param=xxxx
location.hash If the URL contains #, return what comes after that symbol, such as #anchor1
location.assign(“http:www.baidu.com”) To load a new page, as with location.href, the new address is added to the browser’s history stack
location.replace(“http:www.baidu.com”) Same as assign(), but the new address will not be added to the browser’s history stack and cannot be accessed through back and forward
location.reload(true /false) Reload the current page, reloading it from the browser cache when false, or from the server when true, which is false by default
The document object Document == window.document is true and is the only object that is part of both the BOM and DOM