Method properties and lifecycle of Window objects in JavaScript

Source: Internet
Author: User
Tags setinterval

Window objects and browser windows 1:
When a new document is loaded into a window or frame, the window object of that Windows or frame is reset to the default state, that is, all the properties and functions defined by the script in the previous document will be cleared of all existing traces. It has nothing to do with the document opened in the previous window, and the birth is absolutely innocent.
window objects and browser windows 2:
As long as the browser's top-level window exists, the Window object that represents it will always exist. No matter how many pages come and go in this window like a gate, a reference to its window object is valid as long as the browser's top-level window exists. How long does this top-level window open, and how long its window object will be. Its lifecycle is seen as the entire process from beginning to end of the browser process.
window objects and browser Windows 3:
When the window is closed, this window object is not destroyed, and if there is still a reference to the Window object in other Windows, the object will not be recycled by the useless storage unit, although that doesn't really work.
This is like frame A contains a script that references the window object of frame B, and even if the URL address of frame B has changed, Framea's reference to frame B's Window object is still valid. Although it has been reset to the default value, only one read-only property closed exists.
A little explanation:
The Window object referenced by the browser windows always exists as a window handle. The life cycle of a Window object can be considered as the entire process from beginning to end of the browser process. The following code can prove the life cycle of a Window object. Well.. I borrowed it from the book. Oh.

The code is as follows Copy Code
<body>
<script type= ' Text/javascript ' >
New_win = {};
function Createwin ()
{
Creates a new window, new_win the reference handle for the new window
New_win = window.open ();
New_win.document.write ("<input type= ' button ' onclick= ' Window.close (); ' value= ' Close Me ' ></input>");

}
</script>
<input type= ' button ' onclick= ' Createwin (); ' value= ' click me creat win ' ></input>
<input type= ' button ' onclick= ' alert (new_win.closed); ' value= ' alert new win closed status ' ></input>
</body>

The constructor of the

1) window class is invoked and a new window instance is generated. The initialized event for the
      (2) window instance is raised.
      (3) window.activated and application.activated events. The window activated event is raised multiple times during the life cycle of the entire window object, and the secondary event is raised whenever the window becomes the topmost one. Accordingly, the deactivated event is raised when the window changes from a top-level window to a background window. Application.activated may be triggered multiple times throughout the life of the application, triggering the event when the program opens window 1th, or when a user switches to a window in the application by another program.
      (4) window.loaded event. When this event occurs, the window object should have completed the process of outputting to the monitor.
      (5) window.contentrendered event. After the window object is rendered, the contents are output, and the Windowcontentrendered event is raised after the output is finished. After this event is processed, window can interact with the user.
      (6) interacts with the user.
      (7) window.closing event. When you close a Window object, it is generally called when you call the closing method.
      (8) window.unloaded event. The event is raised when the Window object is deleted from the visual element tree.
      (9) window.closed event. This is the last thing in the life cycle. When this event is finished, if the window is the main window of the application, the Application object's Run method returns and the entire program ends.

Properties and methods of the Window object

name Description
Alert Pop-up Simple Prompt box
Attachevent Registration Event (IE only)
Blur Window loses focus
Clearinterval Stop counter Running
Cleartimeout Cancel Timer
Close Close the current window
Confirm Confirmation dialog box
Createpopup Construct pop-up window (IE only)
DetachEvent Unregister event (IE only)
Execscript Execute script (IE only)
Focus window to get focus
Moveby Move a window
MoveTo Move a window
Navigate Browse for a URL
Open Open a new window
Print Print the contents of the document in the current window
Prompt Query dialog box
Resizeby Change the window size
Resizeto Change the window size
Scroll Control scroll bar
Scrollby Control scroll bar
Scrollto Control scroll bar
SetInterval Set up counters
SetTimeout Set timer
ShowHelp Display a Help document (IE only)
ShowModalDialog Modal dialog box (IE only)
showModelessDialog Non-modal dialog box (IE only)
Tostring Convert to String

name Description
Alert Pop-up Simple Prompt box
Attachevent Registration Event (IE only)
Blur Window loses focus
Clearinterval Stop counter Running
Cleartimeout Cancel Timer
Close Close the current window
Confirm Confirmation dialog box
Createpopup Construct pop-up window (IE only)
DetachEvent Unregister event (IE only)
Execscript Execute script (IE only)
Focus window to get focus
Moveby Move a window
MoveTo Move a window
Navigate Browse for a URL
Open Open a new window
Print Print the contents of the document in the current window
Prompt Query dialog box
Resizeby Change the window size
Resizeto Change the window size
Scroll Control scroll bar
Scrollby Control scroll bar
Scrollto Control scroll bar
SetInterval Set up counters
SetTimeout Set timer
ShowHelp Display a Help document (IE only)
ShowModalDialog Modal dialog box (IE only)
showModelessDialog Non-modal dialog box (IE only)
Tostring Convert to String

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.