Is there any way of dynamically picking an html element on the page through the DOM and calculating it's screen position that works in Netscape (4 and 6) and IE?
Thanks in advance for any help.
Ian
Thanks in advance for any help.
Ian
function getPos(obj_id) { var el; if(typeof(document.getElementById)!="undefined") el=document.getElementById(obj_id).style; else if(typeof(document.all)!="undefined") el=document.all[obj_id].style; else if(document.layers!=null) //not sure if NN 4 supports typeof el=document.layers[obj_id]; var pos=new Object(); var pos.x=el.left+screen.width-screen.availWidth; var pos.y=el.top+screen.height-screen.availHeight; return pos; }
var pos=getPos("elementID"); alert(pos.y); alert(pos.x);
Comment