Home Web Front-end JS Tutorial Detailed explanation of JavaScript document and window properties and methods

Detailed explanation of JavaScript document and window properties and methods

Jul 26, 2017 am 10:58 AM
document javascript window

[document object]

This object is a property of the window and frames objects, and is a document displayed in the window or frame.

 Attributes

 alinkColor The color of the active link (ALINK)
 anchor An HTMI anchor point, created using the tag (the attribute itself is also an object)
 anchors array lists the array of document anchor objects (
) (this attribute itself is also an object)
bgColor The background color of the document (BGCOLOR)
Cookies are stored in the cookie.txt file A piece of information, which is an attribute of the document object
 fgColor The text color of the document (TEXT attribute in the tag)
Form A form (

) in the document (this attribute Itself is also an object)
Forms anay lists an array of form objects in the order in which they appear in the document (this property itself is also an object)
LastModified The last modification date of the document
linkColor The link to the document The color, that is, the LINK attribute in the tag (linking to a document that the user has not observed)
 link A
tag in the document (the attribute itself is also an object)
links array An array of link objects in the document, arranged in the order they appear in the document (the property itself is also an object)
Location The URL of the currently displayed document. The user cannot change document.location (because this is the location where the document is currently displayed). However, window.location can be changed (replacing the current document with another document) window.location itself is also an object, and document.location is not an object
referrer contains the URL of the linked document, and the user can click the link to reach the current document
Title The title of the document ((TITLE>)
vlinkColor The text color of the link pointing to the document that the user has observed, that is, the VLINK attribute of the tag

Method

clear Clear the contents of the specified document
Close Close the document stream
Open Open the document stream
Write Write the text into the document
Writeln Write the text into the document and end with a newline character

[window object]

It is a top-level object, not a property of another object, that is, the browser window

DefaultStatus Default. Status bar message
Document The currently displayed document (the property itself is also an object)
frame A frame in the window ((FRAME>) (the property itself is also an object)
frames array Lists the windows An array of frame objects, listed in the order in which these objects appear in the document (this attribute itself is also an object)
 history The history list of the window (this attribute itself is also an object)
 length The number of frames in the window
Location The complete (absolute) URL of the document displayed in the window (this property itself is also an object). Do not confuse it with document.location, which is the URL of the currently displayed document. The user can change window.location (use another one. document replaces the current document), but cannot change document.location (because this is the location where the document is currently displayed)
Name is the name given to the window when the window is opened
opener represents a script that uses window.open to open the current window The window in which it is located (this is a new attribute introduced in Netscape Navigator 3.0beta 3)
 parent is a synonym for the window containing the current frame. An attribute of the frame and window objects
self is a synonym for the current window or frame
status The message in the status bar
Top Synonyms for the topmost browser window containing the current frame
Window Synonyms for the current window or frame, the same as self

Methods

alert( ) Open an Alert message box
ClearTimeout() is used to terminate the work of the setTimeout method
close() Close the window
confirm() Opens a Confirm message box, the user can choose OK or Cancel, if the user clicks OK, this method returns true, click Cancel to return false
 blur() Move the focus from the specified window (this is a new method introduced in Netscape Navigator 3.0 beta 3)
Focus() Bring the specified window to Front desk (another new method)
open() Open a new window
prompt() Open a Prompt dialog box. The user can type text into the box and return the typed text to the script
setTimeout( ) Wait for a specified number of milliseconds, and then run the command event handler

Event handler

Onload() Triggered when the page is loaded
Onunload() Triggered when the page is closed

The above is the detailed content of Detailed explanation of JavaScript document and window properties and methods. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to solve the problem that document.cookie cannot be obtained How to solve the problem that document.cookie cannot be obtained Nov 23, 2023 am 10:02 AM

Solutions for document.cookie not being obtained: 1. Browser privacy settings; 2. Same-origin policy; 3. HTTPOnly Cookie; 4. JavaScript code error; 5. Cookie does not exist or expires; 6. Cross-domain issues; 7. Viewer mode; 8. Server problems; 9. JavaScript execution timing; 10. Check console log, etc.

See all articles