Are you still worried about offset, scroll, inner, client, screen, and mouse? The header is too big. In addition, different browser methods are not the same. Therefore, it is often a waste of time. So I generated a method for users to obtain such data. Introduction
Solve the problem of getting dom elements in various browsers
Compatibility
Ie 6 7 8 firefox 3.6 chrome 4.0 currently only tests these browsers
Author
Jelle lu QQ: 271412542 Email: idche@qq.com blogs: http://www.cnblogs.com/idche/
Source Code Description
Jquery source code is very helpful to me, and also uses the source code of a classmate called bruce lee. Of course, more resources come from the network.
Function Description
// The jelle (elem) object elem transmits the Object ID or dom object. If the object is a window, the window object is passed.
//. Offset () returns the absolute position of the current object relative to the browser. Return Value = {top: a, left: B };
//. Inner () returns the width and height of the visible area of the current object. The returned value is {Hangzhou H: a, left: B };
//. Scroll () returns the top and left areas of the current object. , Return value = {top: a, left: B };
//. Offparent () returns the top left position of the current object from the parent node. , Return value = {top: a, left: B };
//. Client () returns the available height and width of the current object. Return Value: {width: a, height: B };
//. Screen () returns the available height and width of the current screen. Return Value = {width: a, height: B };
//. Mouse (event) returns the x and y coordinates of the current mouse. If elem is not empty, return the coordinates of elem. Return Value: {x: a, y: B };
Example
// Example: return the width of the visible area of p whose ID is test // jelle ('test'). inner (). width // you can directly lower the width next to it.
Jquery-based source code
The Code is as follows:
Untitled document