Advertisement
Guest User

AG

a guest
Nov 29th, 2008
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //centering popup
  2. function getScrollXY() {
  3. var scrOfX = 0, scrOfY = 0;
  4. if( typeof( window.pageYOffset ) == 'number' ) {
  5.   //Netscape compliant
  6.   scrOfY = window.pageYOffset;
  7.   scrOfX = window.pageXOffset;
  8. } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
  9.   //DOM compliant
  10.   scrOfY = document.body.scrollTop;
  11.   scrOfX = document.body.scrollLeft;
  12. } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
  13.   //IE6 standards compliant mode
  14.   scrOfY = document.documentElement.scrollTop;
  15.   scrOfX = document.documentElement.scrollLeft;
  16. }
  17. return {X:scrOfX, Y:scrOfY};
  18. }
  19.  
  20. function getWindowSize() {
  21.  var myWidth = 0, myHeight = 0;
  22.  if( typeof( window.innerWidth ) == 'number' ) {
  23.    //Non-IE
  24.    myWidth = window.innerWidth;
  25.    myHeight = window.innerHeight;
  26.  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  27.    //IE 6+ in 'standards compliant mode'
  28.    myWidth = document.documentElement.clientWidth;
  29.    myHeight = document.documentElement.clientHeight;
  30.  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  31.    //IE 4 compatible
  32.    myWidth = document.body.clientWidth;
  33.    myHeight = document.body.clientHeight;
  34.  }
  35.  return{X:myWidth, Y:myHeight}
  36. }
  37.  
  38. //centering popup
  39. function centerPopup4(){
  40. //request data for centering
  41. var windowDim = getWindowSize();
  42. var popupHeight = $("#popupContact4").height();
  43. var popupWidth = $("#popupContact4").width();
  44. var scroll = getScrollXY();
  45. //centering
  46. $("#popupContact4").css({
  47. "position": "absolute",
  48. "top": windowDim.Y/2-popupHeight/2 + scroll.Y-15,
  49. "left": windowDim.X/2-popupWidth/2 + scroll.X-15
  50. });
  51. //only need force for IE6
  52.  
  53. $("#backgroundPopup4").css({
  54. "height": windowDim.Y
  55. });
  56. //window.alert("\npopup.Height="+popupHeight+"\nInner Height="+windowDim.Y);
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement