This is the 17th day of my participation in the August Text Challenge.More challenges in August
JavaScript can take many objects provided by the browser and manipulate them. Window, Navigator, Screen, location, Document, History.
window
The Window object not only acts as a global scope, but also represents the browser window.
The innerWidth and innerHeight properties get the innerWidth and height 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.
OuterWidth and outerHeight properties to get the entire width and height of the browser window.
navigator
The navigator object represents information about the browser. The most commonly used properties are navigator.appName: the browser name; Navigator. appVersion: Browser version; Navigator. language: the language in which the browser is set; Navigator. platform: Operating system type; Navigator. userAgent: user-agent string set by the browser.
screen
The screen object represents screen information. Common properties are:
- Screen. width: screen width, in pixels;
- Screen. height: Screen height, in pixels;
- Screen. colorDepth: Returns the color number, such as 8, 16, and 24.
location
The location object represents the URL information for the current page. For example, a full URL can be retrieved with location.href
http://www.example.com:8080/path/index.html?a=1&b=2#TOP location.protocol; // 'http' location.host; // 'www.example.com' location.port; // '8080' location.pathname; // '/path/index.html' location.search; / / '? a=1&b=2' location.hash; // 'TOP'Copy the code
To load a new page, call location.assign(). To reload the current page, call the location.reload() method document
The Document object represents the current page. Because HTML is represented as a tree in the BROWSER as a DOM, the Document object is the root node of the entire DOM tree.
The document title attribute is read from
With the getElementById() and getElementsByTagName() provided by the Document object, you can get a DOM node by ID and a set of DOM nodes by Tag name
The Document object also has a cookie property that retrieves the cookie of the current page.
history
The history object holds the browser’s history, and JavaScript can call back() or forward () of the History object, equivalent to the user clicking the browser’s back or forward button. With modern Web pages, because of the heavy use of AJAX and page interaction, a simple and crude call to history.back() can make users very angry. In no case should you use the history object.
\