This article describes the built-in objects in javascript, including image objects, navigation objects, window objects, screen objects, event objects, historical objects, and file objects (important), anchor object, link object, frame object, form object (important), location object. Here is a brief introduction, which will be explained in detail later.
JS Window
Window object: http://www.w3school.com.cn/js/js_window.asp
All browsers support window objects. It indicates the browser window.
All JavaScript global objects, functions, and variables are automatically members of the window object.
Properties and method formats of window objects:
[Window.] Properties
[Window.] method (parameter)
Even the document of html dom is one of the properties of the window object:
Optional parameter Doc ument. 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 attributes of the screen.
Properties of the Screen Object:
Format: screen. Properties
Screen. availWidth-available screen width
Screen. availHeight-available screen height
In pixels, subtract the interface features, such as the window taskbar.
JS Location
Location object: http://www.w3school.com.cn/js/js_window_location.asp
A location object is used to represent the URL Information of a specific window.
The window. location object does not use the window prefix when writing.
Some examples:
Location. hostname: The domain name of the web host.
Location. pathname: return the path and file name of the current page.
Location. port returns the port (80 or 443) of the web host)
Location. protocol returns the web protocol used (http: // or https ://)
The location. href attribute returns the URL of the current page.
The location. assign () method loads a new document.
JS History
History Object: http://www.w3school.com.cn/js/js_window_history.asp
Historical objects are used to store the list of recently accessed URLs of the client.
To protect user privacy, the methods for accessing this object by JavaScript are limited.
Some methods:
History. back ()-same as clicking the back button in the browser
History. forward ()-same as clicking the button in the browser to forward
Object
File object: indicates the current HTML object, which is composedThe tag group automatically creates a file object for each HTML file.
Format:
Document. Attributes
Document. Method (parameter)
Link object
Links in the web page are automatically treated as link objects, which are displayed in order as document. links [0], document. links [1]...
Define the format of the link object:
String. link (attribute)
Form object
The object sub-object. The Javascript runtime engine automatically creates a form object for each form.
Format:
Document. forms [Index]. Attributes
Document. forms [Index]. Method (parameter)
Document. form name. Attribute
Document. form name. Method (parameter)