here are some valuable javascript functions for getting window width and height a long with the get element X position, and Y position all of this functions are not my invention; its copied from the website and blog listed in the reference list.
lets start with getWindowDimension:
function getWindowDimension(isWidth)var winW = 630, winH = 460;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") { winW = window.innerWidth-16; winH = window.innerHeight-16; } if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.body.offsetWidth-20; winH = document.body.offsetHeight-20; }
} return (isWidth)? winW : winH; }
the following are getXPosition and getYPosition:
function findPosX(obj) {var curleft = 0; if(obj.offsetParent) { while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; }
} else if(obj.x) curleft += obj.x; return curleft; } function findPosY(obj) {
var curtop = 0; if(obj.offsetParent) {
while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) break; obj = obj.offsetParent; }
} else if(obj.y) curtop += obj.y; return curtop; }
References:
- http://www.javascripter.net/faq/browserw.htm
- http://blog.firetree.net/2005/07/04/javascript-find-position/

Recent comments
2 weeks 17 hours ago
15 weeks 5 days ago
16 weeks 12 hours ago
16 weeks 12 hours ago
27 weeks 3 days ago
31 weeks 4 days ago
32 weeks 5 days ago
1 year 2 days ago
1 year 2 days ago
1 year 4 weeks ago