diff options
author | Andrew Dolgov <[email protected]> | 2006-03-20 12:24:34 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2006-03-20 12:24:34 +0100 |
commit | c38c2b69c9479817291ac06042fb5529b24f33f0 (patch) | |
tree | b967ccc6c5f6f632b8d3ee0cacd66ddb01c0562b /functions.js | |
parent | 991ee9e2b5cd12bccf89f5321756a5b4180981ed (diff) |
center infobox on screen
Diffstat (limited to 'functions.js')
-rw-r--r-- | functions.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/functions.js b/functions.js index 58ef1bfc7..92bcc3bf9 100644 --- a/functions.js +++ b/functions.js @@ -868,3 +868,20 @@ function leading_zero(p) { if (s.length == 1) s = "0" + s; return s; } + +function center_element(e) { + var c_width = document.body.clientWidth; + var c_height = document.body.clientHeight; + + var c_scroll = document.body.scrollTop; + + var e_width = e.clientWidth; + var e_height = e.clientHeight; + + var set_y = (c_height / 2) + c_scroll - (e_height / 2); + var set_x = (c_width / 2) - (e_width / 2); + + e.style.top = set_y + "px"; + e.style.left = set_x + "px"; + +} |