Some JS application skills

Source: Internet
Author: User

1. Keep the layer at the beginning without being overwritten by IFRAME and object.
Insert the IFRAME or object in the layer to set the Z-index value.
<Div Z-index: 2> <object XXX> </Object> # front
<Div Z-index: 1> <object XXX> </Object> #
<Div id = "Layer2" style = "position: absolute; top: 40; width: 400px;
Height: 95px; Z-index: 2 "> Height = 100% width = 100%>
<IFRAME width = 0 Height = 0> </iframe>
</Div>
<Div id = "layer1" style = "position: absolute; top: 50; width: 200px;
Height: 115px; Z-index: 1 ">
<IFRAME Height = 100% width = 100%> </iframe> string 6
</Div>

2. Obtain the absolute position of the control
// Javascript
<Script language = "JavaScript">
Function getie (e ){
VaR T = E. offsettop;
VaR L = E. offsetleft;
While (E = E. offsetparent ){
T + = E. offsettop;
L + = E. offsetleft;
}
Alert ("Top =" + T + "/nleft =" + l );
}
</SCRIPT>

 

Getnowobjectposition: function (){
This. OBJ =;
VaR B = A. offsetleft;
VaR c = A. offsettop;
VaR d = A. offsetparent;
While (D! = NULL ){
If (D. tagname! = "Body "){
B + = D. offsetleft;
C + = D. offsettop;
D = D. offsetparent
}
Else {
B + = Document. Body. offsetleft | 0;
C + = Document. Body. offsettop | 0;
Break
}
}
Return {
X: B,
Y: c
}
},

VaR c = myutility. getnowobjectposition (objplaceid );
Newmask. style. Top = C. Y + "PX ";
Newmask. style. Left = C. x + "PX ";

3. The script will never go wrong
<Script language = "JavaScript">
<! -- Hide
Function killerrors (){
Return true;
}
Window. onerror = killerrors;
// -->
</SCRIPT>

 

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.