search
HomeWeb Front-endJS TutorialCompilation of information related to js window object properties and methods_javascript skills

The window object has the following methods:

open close alert confirm prompt setTimeout clearTimeout setInterval clearInterval moveBy moveTo resizeBy resizeTo scrollBy scrollTo find back forward home stop print blur focus captureEvent enableExternalCapture disableExternalCapture handleEvent releaseEvent routeEvent scroll

1. open method

Syntax format: window.open(URL, window name, window style)

Function: Open a new window and load the web page with the specified URL address in the window.

Description:

The open method is used to open a new browser window and load a specified URL address in the new window;

When opening a new browser window, the open method can also specify the name of the window (the second parameter);

When opening a new browser window, the open method can also specify the style of the window (the third parameter). The window style has the following options. These options can be multiple selected. If multiple selections are made, use commas between each option. Separator:

toolbar: Specifies whether the window has a standard toolbar. When the value of this option is 1 or yes, it means there is a standard toolbar; when the value of this option is 0 or no, it means there is no standard toolbar;

location: Specifies whether the window has an address toolbar. The value and meaning of the option are the same as toolbar;
directories: Specify whether the window has a link toolbar. The value and meaning of the option are the same as toolbar;
status: Specifies whether the window has a status bar. The value and meaning of the option are the same as toolbar;
menubar: Specifies whether the window has a menu. The value and meaning of the option are the same as toolbar;
scrollbar: Specifies whether there is a scroll bar when the current window document is larger than the window. The value and meaning of the option are the same as toolbar;
resizable: Specifies whether the window can be resized. The value and meaning of the option are the same as toolbar;
width: Specifies the width of the window in pixels, replaced by innerWidth;
height: Specifies the height of the window in pixels, which has been replaced by innerHeight;
outerWidth: Specifies the outer width of the window in pixels;
outerHeight: Specifies the outer height of the window in pixels;
left: Specifies the position of the window from the left side of the screen in pixels;
top: Specify the position of the window from the top of the screen in pixels;
alwaysLowered: The specified window is hidden behind all windows. The value and meaning of the option are the same as toolbar;
alwaysRaised: The specified window floats on top of all windows. The value and meaning of the option are the same as toolbar;
dependent: Specifies that the opened window is a child window of the current window and will be closed when the parent window is closed. The value and meaning of the option are the same as toolbar;
hotkeys: Set the hotkey for safe exit in a new window without a menu bar. The value and meaning of the option are the same as toolbar;
innerHeight: Set the pixel height of the document in the window;
innerWidth: Set the pixel width of the document in the window;
screenX: Set the pixel length of the window from the left edge of the screen;
screenY: Set the pixel length of the window from the upper border of the screen;
titleBar: Indicates whether the title bar is visible in the new window. The value and meaning of the option are the same as toolbar;
z-look: Indicates that when the window is activated, it cannot float on top of other windows. The value and meaning of the option are the same as toolbar.
The open method returns a reference to the window.

Tips: This method is often used to automatically open another window when opening a web page.

2. close method

Syntax format: window.close()

Function: The close method is used to automatically close the browser window.

3. alert method

Syntax format: window.alert(prompt string)

Function: Pop up a warning box and display the prompt string text in the warning box.

4. confirm method

Syntax format: window.confirm(prompt string)

Function: Display a confirmation box and display a prompt string in the confirmation box. This method returns true when the user clicks the "OK" button and returns false when the user clicks "Cancel".

5. prompt method

Syntax format: window.prompt (prompt string, default text)

Function: Display an input box, display the prompt string in the input box, display the default text in the input text box, and wait for user input. When the user clicks the "OK" button, return the string entered by the user. When the Cancel button is clicked, a null value is returned.

6. setTimeout method

Syntax format: window.setTimeout(code character expression, milliseconds)

Function: Timing setting, automatically execute the code character expression after the specified number of milliseconds.

7. clearTimeout method

Syntax format: window.clearTimeout(timer)

Function: Cancel the previous timing setting. The parameter is the return value when set with setTimeout.

8. setInterval method

Syntax format: window.setInterval(code character expression, milliseconds)

Function: After setting a time interval (second parameter), repeatedly execute the content of "code character expression"

9. clearInterval method

Syntax format: window.clearInterval (time interval)

Function: Cancel the timing set by setInterval. The parameter is the return value of the setInterval method.

10. moveBy method

Syntax format: window.moveBy(horizontal displacement, vertical displacement)

Function: Move the specified window according to the given pixel parameters. The first parameter is the pixel by which the window moves horizontally, and the second parameter is the pixel by which the window is moved vertically.

11.moveTo method

Syntax format: window.moveTo(x,y)

Function: Move the window to the specified specified coordinates (x, y).

12. resizeBy method

Syntax format: window.resizeBy(horizontal, vertical)

Function: Change the current window to the specified size (x, y). When the values ​​​​of x and y are greater than 0, it is expanded, and when it is less than 0, it is reduced.

13. resizeTo method

Syntax format: window.resizeTo(horizontal width, vertical width)

Function: Change the current window to (x, y) size, where x and y are the width and height respectively.

14. scrollBy method

Syntax format: window.scrollBy(horizontal displacement, vertical displacement)

Function: Scroll the content in the window by a given displacement. When the parameter is a positive number, scroll forward, otherwise scroll in the reverse direction.

15. scrollTo method

Syntax format: window.scrollTo(x,y)

Function: Scroll the content in the window to the specified position.

16.find method

Syntax format: window.find()

Function: When this method is triggered, a "find" dialog window will pop up and allow the user to find a string in the page that triggered the find method.

Note: This attribute is not supported in IE5.5 and Netscape6.0.

17. back method

Syntax format: window.back()

Function: Simulate the user clicking the "Back" button on the browser to move the page to the previous page of the browser.

Note: This operation can only be performed when the current page has a previous page.

Note: IE5.5 does not support this method, but Netscape6.0 does.

18. forward method

Syntax format: window.forward()

Function: Simulate the user clicking the "Forward" button on the browser to move the page to the next page of the browser.

Note: This operation can only be performed when the next page exists on the current page.

Note: IE5.5 does not support this method, but Netscape6.0 does.

19. home method

Syntax format: window.home()

Function: Simulate the user clicking the "Home" button on the browser to redirect the page to the specified page.

Note: IE5.5 does not support this method, but Netscape6.0 does.

20. stop method

Syntax format: window.stop()

Function: Simulate the user clicking the "Stop" button on the browser to terminate the browser's download operation.

Note: IE5.5 does not support this method, but Netscape6.0 does.

21. print method

Syntax format: window.print()

Function: Simulate the user clicking the "Print" button on the browser to notify the browser to open the print dialog box and print the current page.

22. blur method

Syntax format: window.blur()

Function: Remove focus from the window. Care must be taken when used with the focus method, as this may cause the focus to continually move in and out.

23. focus method

Syntax format: window.focus()

Function: Make the window focus. Be careful when using it with the blur method as it may cause focus to move in and out

24. captureevent method

Syntax format: window.captureevent(event)

window.captureevent(event1|event2|…|eventn)

Function: Capture all events with specified parameters. Because of the ability to capture events that are handled by the local program itself, programmers can freely define functions to handle events. If there are multiple events that need to be captured, use the pipe character "|" to separate each event. The event types that can be captured are as follows:

event.abortevent.blurevent.changeevent.clickevent.dblclickevent.dragdropevent.errorevent.focusevent.keydownevent.keypressevent.keyupevent.loadevent.mousedownevent.mousuemoveevent.mouseoutevent. mouseover event.mouseup event.move event.reset event.resize  event.select event.submit event.unload

25. enableexternalcapture event

Syntax format: window.enableexternalcapture(event)

Function: The enableexternalcapture method is used to capture external events passed in through parameters.

26. disableexternalcapture event

Syntax format: window.disableexternalcapture()

Function: Cancel the setting of the enableexternalcapture method and terminate the capture of external events.

27. handleevent event

Syntax format: window.handleevent(event)

Function: Event handler that triggers the specified event.

28. releaseevent event

Syntax format: window.releaseevent(event)

window.releaseevent(event1|event2|…|eventn)

Function: Release the captured events passed in through parameters. These events are set by the window.captureevent method. The releasable events are the same as captureevent.

29. routeevent event

Syntax format: window.releaseevent(event)

Function: Transfer all events of the captured type to standard event processing methods for processing. The events that can be transferred are the same as captureevent.

30. scroll event

Syntax format: window.scroll(x coordinate, y coordinate)

Function: Move the window to the specified coordinate position.

Properties of window object

The window object has the following properties:

status statusbar statusbar.visible defaultstatus location locationbar locationbar.visible self name closed frames frames.length document history innerheight innerwidth menubar menubar.visible opener outerheight outerwidth pagexoffset pageyoffset parent personalbar personalbar.visiblescrollbar scroll bar.visible toolbar toolbar.visible top

1. status attribute

Syntax format: window.status=string

Function: Set or give the current display information of the status bar in the browser window.

Tips: You can use this attribute to set the browser window status bar information.

2. statusbar attribute

Syntax format: window.statusbar.Attribute

Function: The statusbar attribute itself is also an object, used to access its own visible attribute to determine whether the status bar is visible.

Note: IE5.5 browser does not support this attribute.

3. statusbar.visible property

Syntax format: window.statusbar.visible

Function: Check whether the status bar is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 browser does not support this attribute.

4. defaultstatus attribute

Syntax format: window.defaultstatus[=string]

Function: The defaultstatus attribute value is the default display information of the status bar in the browser window

5.location attribute

Syntax format: window.location=url

Function: Give the url information of the current window or specify the url of the open window.

6. locationbar attribute

Syntax format: window.locationbar.property

Function: The locationbar attribute can also be regarded as a sub-object. This attribute is used to obtain its own visible attribute to determine whether the location bar is visible. So far, this property has only one subproperty: visible.

Note: IE5.5 does not support this attribute.

7. locationbar.visible property

Syntax format: window.locationbar.visible

Function: Returns whether the location bar is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 does not support this attribute.

8. self attribute

Syntax format: window.self.method

window.self.Property

Function: This attribute contains the flag of the current window. Using this attribute, you can ensure that when multiple windows are opened, the functions or properties in the current window are correctly called without confusion.

9. name attribute

Syntax format: window.name=name

Function: Returns the window name, which is given when the window.open() method creates a new window. In the JavaScript 1.0 version, this attribute can only be used to read the window name. In the JavaScript 1.1 version, you can use this attribute to specify a name for a window that is not created using the window.open() method.

10. closed attribute

Syntax format: window.closed

Function: The closed attribute is used to return whether the instance of the specified window has been closed. If it is closed, it returns true, otherwise it returns false.

11. frames attribute

Syntax format: window.frames["frame name"]

window.frames[numeric]

Function: The frames attribute is an array, used to store each sub-window (frame) instance created by an element in the document. The subscript can be the sequence number or the name specified by the name attribute of the frame element. to get and use.

12. frames.length property

Syntax format: window.frames.length

Function: The frames.length attribute is used to give the number of sub-window (frame) instances in the document.

13. length attribute

Syntax format: window.length

Function: The length attribute returns the number of sub-windows in a window. This attribute has the same value as the window.frame.length attribute.

14. document attribute

Syntax format: window.document.event window.document.method window.document.property

Function: The sub-object document of the window object is the core object of JavaScript. An instance is created when the body element is encountered in the script.

15. history attribute

Syntax format: window.history[value] window.history.method() window.history.property

The sub-object history of the window object is one of the core objects of JavaScript. This attribute contains an array of the names and URLs of the pages that have been visited.

16. innerheight property

Syntax format: window.innerheight=numeric value

Function: Return or specify the pixel height of the document in the browser window. This height does not include the height of any toolbars and page modifications that make up the window.

Note: IE5.5 does not support this attribute.

17. innerwidth attribute

Syntax format: window.innerheight=numeric value

Function: Return or specify the pixel width of the document in the browser window. This width does not include the width of any toolbars and page modifications that make up the window.

Note: IE5.5 does not support this attribute.

18. menubar attribute

Syntax format: window.menubar.Attribute

Function: The menubar attribute can also be regarded as a sub-object. This attribute is used to obtain its own visible attribute to determine whether the menu bar is visible. So far, this property has only one subproperty: visible.

Note: IE5.5 does not support this attribute.

19. menubar.visible property

Syntax format: window.menubar.visible

Function: The menubar.visible property is used to return whether the menu bar is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 does not support this attribute.

20. opener attribute

Syntax format: window.opener | window.opener.method | window.opener.property

Function: The opener attribute is associated with the parent window that opens the window. When accessing the operer attribute in the child window, the parent window is returned. This property provides access to methods and properties from the parent window object.

21. outerheight attribute

Syntax format: window.outerheight

Function: The outerheight attribute is used to access the pixel height of the browser window, which includes the height of toolbars and decorative edges.

Note: IE5.5 does not support this attribute.

22. outerwidth attribute

Syntax format: window.outerwidth

Function: The outerwidth attribute is used to access the pixel width of the browser window, which includes the width of toolbars and decorative edges.

Note: IE5.5 does not support this attribute.

23. pagexoffset attribute

Syntax format: window.pagexoffset=numeric value

Function: Specify the current horizontal pixel position of the upper left corner of the document in the browser window in the window. Before using moveto to move, you can use this property to decide whether the window needs to be moved. Because this property returns the current position of the visible document relative to the entire page.

Note: IE5.5 does not support this attribute.

24. pageyoffset attribute

Syntax format: window.pageyoffset=numeric value

Function: Specify the current vertical pixel position of the upper left corner of the document in the browser window in the window. Before using moveto to move, you can use this property to decide whether you need to move the window. Because this property returns the current position of the visible document relative to the entire page.

Note: IE5.5 does not support this attribute.

25. parent attribute

Syntax format: window.parent.frames[numeric] window.parent.framesname

Function: Access the parent window where each child window (multi-frame) is located.

26. personalbar attributes

Syntax format: window.personalbar.property

Function: The personalbar attribute itself is also an object, which is used to access its own visible attribute to determine whether the personal bar is visible.

Note: IE5.5 does not support this attribute.

27. personalbar.visible property

Syntax format: window.personalbar.visible

Function: Determine whether the personal column is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 does not support this attribute.

28. scrollbars properties

Syntax format: window.scrollbars.property

Function: The scrollbars property itself is also an object, used to access its own visible property to determine whether the scroll bar is visible

Note: IE5.5 does not support this attribute.

29. scrollbars.visible property

Syntax format: window.scrollbars.visible

Function: scrollbars.visible is used to determine whether the scroll bar is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 does not support this attribute.

30. toolbar attribute

Syntax format: window.toolbar.property

Function: The toolbar attribute itself is also an object, used to access its own visible attribute to determine whether the toolbar is visible.

Note: IE5.5 does not support this attribute.

31. toolbar.visible property

Syntax format: window.toolbar.visible

Function: The toolbar.visible property is used to check whether the toolbar is visible. If it is visible, it returns true, otherwise it returns false.

Note: IE5.5 does not support this attribute.

32. top attribute

Syntax format: window.top.frames[numeric] window.top.framename window.top.method()

window.top.property

Function: The top attribute of the window object is used to contain information about the topmost window of all sub-windows (multi-frames) loaded into the browser.

Statement
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
Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

See all articles

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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.