In JavaScript, window means "window" and is a built-in host object that represents the browser window. All browsers support this object. All JavaScript global objects, functions, and variables will automatically become members of the window object.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
In JavaScript, window means "window" and is a built-in host object.
The window object is the core of all objects in the BOM. In addition to being the parent object of all objects in the BOM, it also contains some window control functions.
The host object is the object provided by the environment that executes the JS script, and is the object provided by the browser. All BOM and DOM are host objects.
Window object
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.
Global variables are properties of the window object.
Global functions are methods of the window object.
Even the document of HTML DOM is also one of the attributes of the window object:
window.document.getElementById("header");
Copy after login
Same as this:
document.getElementById("header");
Copy after login
1. Global window object
Any global function or variable in JavaScript is a property of window.
<script type="text/javascript">
var name="撼地神牛";
document.write(window.name);
</script>
Copy after login
2. Window and self objects
The self object is exactly the same as the window object. Self is usually used to confirm that it is in the current form.
The main objects of window mainly include the following:
JavaScript document object
JavaScript frames object
JavaScript history object
JavaScript location object
JavaScript navigator object
JavaScript screen object
4. Window function index (only valid for IE)
Form control Function:
JavaScript moveBy() Function: Move the form x pixels horizontally and y pixels vertically from the current position. If x is a negative number, it will move the form to the left. A negative y will move the form upward.
JavaScript moveTo() function: Move the upper left corner of the form to the (x, y) point relative to the upper left corner of the screen. When a negative number is used as a parameter, the form will be moved out of the screen. visible area.
JavaScript resizeBy() function: Relative to the current size of the form, adjust the width by w pixels and the height by h pixels. If the parameter is negative, the form will be reduced, otherwise it will be enlarged.
JavaScript resizeTo() function: Adjust the width of the form to w pixels and the height to h pixels.
JavaScript scrollTo() function: If there is a scroll bar in the form, it will scroll horizontally The bar is moved to a position x pixels relative to the width of the form, and the vertical scroll bar is moved to a position y pixels relative to the height of the form.
JavaScript scrollBy() function: If there is a scroll bar, move the horizontal scroll bar to a position of x pixels relative to the current horizontal scroll bar (that is, move x pixels to the left), Move the vertical scroll bar to a position that is y pixels relative to the height of the current vertical scroll bar (that is, move y pixels downward).
Note the difference, one is relative to the current window, and the other is relative to the current position of the scroll bar.
JavaScript open() function: Open (pop-up) A new form
JavaScript close() function: close the form
JavaScript opener attribute: Communication between cross-forms can be achieved through opener, but it must be under the same domain name , and one form should contain the opener of another form.
window.open(url, name, features, replace);
Open function parameter description:
url -- to load the form URL;
name -- the name of the new form (can also be the value of the HTML target attribute, target);
features -- a string representing the form's features, a string Each attribute in is separated by commas;
replace -- a Boolean value indicating whether the newly loaded page replaces the currently loaded page. This parameter is usually not specified.
First use a normal HTML link to open a page (target named dreamdu), and then use the open function to open another page. The browser first needs to find whether There is a form named dreamdu. If so, load the open address in this form.
The above is the detailed content of What does window mean in javascript. 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
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 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
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 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 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
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
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).
Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service