Gets the function of the real, final CSS style attribute value of the element
function GetStyle (elem,name) {
if (Elem.style[name]) {
return Elem.style[name];
}else if (elem.currentstyle) {
return Elem.currentstyle[name];
}else if (Document.defaultview && document.defaultView.getComputedStyle) {
name = Name.replace ([[A-z])/g, "-$1");
Name = Name.tolowercase ();
var s = document.defaultView.getComputedStyle (Elem, "");
return s && s.getpropertyvalue (name);
}else{
return null;
}
}
Two secondary positions that determine the x and Y positions of elements relative to the entire document
function Pagex (elem) {
Return elem.offsetparent?
Elem.offsetleft+pagex (elem.offsetparent):
Elem.offsetleft;
}
function Pagey (elem) {
Return elem.offsetparent?
Elem.offsettop+pagey (elem.offsetparent):
Elem.offsettop;
}
Two functions to determine the position of an element relative to the father
function Parentx (elem) {
return Elem.parentnode = = Elem.offsetparent?
Elem.offsetleft:
Pagex (Elem)-pagex (Elem.parentnode);
}
function Parenty (elem) {
Return elem.parentnode==elem.offsetparent?
Elem.offsettop:
Pagey (Elem)-pagey (Elem.parentnode);
}
Determines the position of an element relative to its CSS container
function Posx (elem) {
Return parseint (GetStyle (Elem, "left"));
}
function Posy (elem) {
Return parseint (GetStyle (Elem, "top"));
}
function to set element x and Y positions independent of current position
function SetX (elem,pos) {
Elem.style.left = pos+ "px";
}
function Sety (elem,pos) {
Elem.style.top = pos+ "px";
}
function to adjust the distance of an element relative to the current position
function Addx (elem,pos) {
SetX (Posx (elem) +pos);
}
Function Addy (Elem,pos) {
Sety (Posy (elem) +pos);
}
Gets the current height and width of the element
function GetHeight (elem) {
Return parseint (GetStyle (elem, ' height '));
}
function GetWidth (elem) {
Return parseint (GetStyle (elem, ' width '));
}
That is, the element is hidden, and it can also get two functions of its potential full height and width, respectively.
function Fullheight (elem) {
if (GetStyle (Elem, ' Display ')!= ' none ') {
return Elem.offsetheight| | GetHeight (Elem);
}
var old = Resetcss (elem,{
Display: ',
Visibility: ' Hidden ',
Position: ' Absolute '
});
var h = elem.clientheight| | GetHeight (Elem);
Restorecss (Elem,old);
return h;
}
function Fullwidth (elem) {
if (GetStyle (Elem, ' Display ')!= ' none ') {
return Elem.offsetwidth | | GetWidth (Elem);
}
var old = Resetcss (elem,{
Display: ',
Visibility: ' Hidden ',
Position: ' Absolute '
});
var w = elem.clientwidth | | GetWidth (Elem);
Restorecss (Elem,old);
Return w;
}
function Resetcss (elem,prop) {
var old = [];
for (var i in prop) {
Old[i] = Elem.style[i];
Elem.style[i] = Prop[i];
}
return old;
}
function Restorecss (elem,prop) {
for (var i in prop) {
Elem.style[i] = Prop[i];
}
}
A set of functions that use the Display property of CSS to toggle element visibility
function Hide (elem) {
var curdisplay = GetStyle (elem, ' Display ');
if (Curdisplay!= ' None ') {
Elem. $oldDisplay = Curdisplay;
}
Elem.style.display = ' None ';
}
Function Show (elem) {
Elem.style.display = elem. $oldDisplay | | ';
}
Set the transparency of an element
function SetOpacity (elem,level) {
if (elem.filters) {
Elem.style.filters = ' alpha (opacity= ' +level+ ') ';
}else{
elem.style.opacity = level/100;
}
}
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