MooTools "Ten"-the expansion of windows and the colorful world

Source: Internet
Author: User

One. MooTools framework for Windows extension:

The browser's Window object itself provides many of our methods of acquiring or setting the properties of the browser itself, but we also know that because of the lack of uniformity of standards between the major browsers, many methods function in different ways, mootools for us to unify our most commonly used methods:

MooTools's Window.Base.js, the main implementation of the DOM tree creation completed event monitoring. Previously, we could often write JavaScript code at the end of the HTML code by adding the defer attribute to ensure that the HTML the JavaScript code is to manipulate is loaded before the JavaScript code (if not, JavaScript will not get the target element, but it still looks too cluttered and Pau is not the highest. In fact, like IE words can be based on the document's ReadyState attribute to determine the establishment of the tree of documents, and some browsers after the creation of the document tree will trigger the onload event, MooTools wrapped it up to form a unified custom event "Domready" , you can add the listener method for the Domready event to the window just as you would add other listeners:

Window.addevent (' Domready ', function () {

Alert (' The DOM is ready ');

});

NOTE:---This is why you always add events to the page by using the MooTools frame: window.addevent (' Domready ', function () {//operation content ...} The reason for the start. This ensures that the HTML the JavaScript code will manipulate is preceded by the JavaScript code mount (if not, JavaScript will not get the target element and error)

In addition, there is a quick way to effect the same as the above:

Window.ondomready (function (e) {

Alert (' DOM is ready!!! ');

});

MooTools's Window.Size.js provides a series of tool methods related to the size of the browser window.

Window extension methods:

GetWidth: Gets the window's current height (does not contain the scroll volume of the scroll bar, which is currently visible

View height)

GetHeight: Gets the current width of the window (does not contain the scroll of the scroll bar, that is, the current visibility width)

Getscrollwidth: Gets the window's current height (including the entire content area, which is also counted in the scrolling section)

Getscrollheight: Gets the current width of the window (contains the entire content area, which is also counted in the scrolling section)

Getscrollleft: Gets the horizontal offset of window scrolling

Getscrolltop: Gets the vertical offset of window scrolling

GetSize: Get the data provided by several methods above window, format:

{

' Size ': {' x ': This.getwidth (), ' Y ': This.getheight ()},

' Scrollsize ': {' x ': This.getscrollwidth (), ' Y ': This.getscrollheight ()},

' Scroll ': {' x ': This.getscrollleft (), ' Y ': This.getscrolltop ()}

}

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.