& Lt; style & gt; html, body {font-size: 12px; margin: 0px; height: 100% ;}. mesWindow {border: #6661 pxsolid; background: # fff ;}. mesWindowTop {border-bottom: # eee1pxsolid; margin-le
Script
Var isIe = (document. all )? True: false;
// Set the visible status of select
Function setSelectState (state ){
Var objl = document. getElementsByTagName ('select ');
For (var I = 0; I <objl. length; I ++ ){
Objl [I]. style. visibility = state;
}
}
Function mousePosition (ev ){
If (ev. pageX | ev. pageY ){
Return {
X: ev. pageX,
Y: ev. pageY
};
}
Return {
X: ev. clientX + document. body. scrollLeft
-Document. body. clientLeft,
Y: ev. clientY + document. body. scrollTop-document. body. clientTop
};
}
// Pop-up method
Function showMessageBox (wTitle, content, pos, wWidth ){
CloseWindow ();
Var bWidth = parseInt(document.doc umentElement. scrollWidth );
Var bHeight = parseInt(document.doc umentElement. scrollHeight );
If (isIe ){
SetSelectState ('den den ');
}
Var back = document. createElement ("div ");
Back. id = "back ";
Var styleStr = "top: 0px; left: 0px; position: absolute; background: #666; width :"
+ BWidth + "px; height:" + bHeight + "px ;";
StyleStr + = (isIe )? "Filter: alpha (opacity = 0);": "opacity: 0 ;";
Back.style.css Text = styleStr;
Document. body. appendChild (back );
ShowBackground (back, 50 );
Var mesW = document. createElement ("div ");
MesW. id = "mesWindow ";
MesW. className = "mesWindow ";
MesW. innerHTML =" "
+ WTitle
+""
+ Content + "";
StyleStr = "left: 0px; top: 25px; position: absolute ;";
MesW.style.css Text = styleStr;
Document. body. appendChild (mesW );
}
// Gradually darken the background
Function showBackground (obj, endInt ){
If (isIe ){
Obj. filters. alpha. opacity + = 1;
If (obj. filters. alpha. opacity <endInt ){
SetTimeout (function (){
ShowBackground (obj, endInt)
}, 5 );
}
} Else {
Var al = parseFloat (obj. style. opacity );
Al ++ = 0.01;
Obj. style. opacity = al;
If (al <(endInt/100 )){
SetTimeout (function () {www.2cto.com
ShowBackground (obj, endInt)
}, 5 );
}
}
}
// Close the window
Function closeWindow (){
If (document. getElementById ('back ')! = Null ){
Document. getElementById ('back'). parentNode. removeChild (document
. GetElementById ('back '));
}
If (document. getElementById ('meswindow ')! = Null ){
Document. getElementById ('meswindow'). parentNode
. RemoveChild (document. getElementById ('meswindow '));
}
If (isIe ){
SetSelectState ('');
}
}
// Test the pop-up
Function testMessageBox (ev ){
Var objPos = mousePosition (ev );
MessContent = "";
ShowMessageBox ('', messContent, objPos, 1550 );
}
Script
// The following code is written in the body to call the above method.
This article is from the "3345617" blog