Showdiv ($ ("# showdiv "));
Function showdiv (OBJ ){
$ (OBJ). Show ();
Center (OBJ );
$ (Window). Scroll (function (){
Center (OBJ );
});
$ (Window). Resize (function (){
Center (OBJ );
});
}
Function center (OBJ ){
VaR export wwidth = document.doc umentelement. clientwidth;
VaR transport wheight = document.doc umentelement. clientheight;
VaR popupheight = $ (OBJ). Height ();
VaR popupwidth = $ (OBJ). Width ();
((Obj).css ({
"Position": "absolute ",
"TOP": (windowheight-popupheight)/2 + $ (document). scrolltop (),
"Left": (repeated wwidth-popupwidth)/2
});
}
In addition, the css of the Div must include:
Position: absolute;
Then attach the disabled scroll bar:
VaR temp_h1 = Document. Body. clientheight;
VaR temp_h2 = document.doc umentelement. clientheight;
VaR isxhtml = (temp_h2 <= temp_h1 & temp_h2! = 0 )? True: false;
VaR htmlbody = isxhtml? Document.doc umentelement: Document. Body;
Htmlbody. style. Overflow = "Auto"; // enable
Htmlbody. style. Overflow = "hidden"; // disable
Then everything is OK
It is said that people who do not reply often play debug