Home > Article > Web Front-end > JavaScript study notes built-in objects_basic knowledge
JS Window
Window object: http://www.w3school.com.cn/js/js_window.asp
All browsers support the window object. It represents the browser window.
All JavaScript global objects, functions and variables automatically become members of the window object.
Properties and methods format of window object:
[window.]Property
[window.]Method (parameter)
Even the document of HTML DOM is one of the attributes of the window object:
window.document.getElementById("header");
Same as this:
document.getElementById("header");
JS Screen
Screen object: http://www.w3school.com.cn/js/js_window_screen.asp
The screen object mainly describes the display and color properties of the screen.
Properties of the screen object:
Format: screen.Attribute
Screen.availWidth - Available screen width
Screen.availHeight - available screen height
Measured in pixels, minus interface features such as the window taskbar.
JS Location
Location object: http://www.w3school.com.cn/js/js_window_location.asp
The location object is used to represent the URL information of a specific window.
The window.location object can be written without the window prefix.
Some examples:
Location.hostname returns the domain name of the web host
Location.pathname returns the path and file name of the current page
Location.port returns the port of the web host (80 or 443)
Location.protocol returns the web protocol used (http:// or https://)
The location.href property returns the URL of the current page.
The location.assign() method loads a new document.
JS History
Historical objects: http://www.w3school.com.cn/js/js_window_history.asp
The history object is used to store the list of URLs recently visited by the client.
In order to protect user privacy, JavaScript’s method of accessing this object is restricted.
Some methods:
History.back() - Same as clicking the back button in the browser
History.forward() - Same as clicking the button forward in the browser
File Object
File object: Represents the current HTML object, which is composed of
tag group. A file object will be automatically created for each HTML file.Format:
Document.Attribute
Document.Method (parameter)
Link object
The links in the web page will be automatically regarded as link objects, and in order, they are represented as document.links[0], document.links[1]...
Define the format of the link object:
String.link(property)
Form Object
As a sub-object of the file object, Javascript’s runtime engine automatically creates a form object for each form.
Format:
document.forms[index].Properties
document.forms[index].Method (parameter)
Document.Form name.Attribute
Document.Form name.Method (parameter)