本文實(shí)例講述了JS實(shí)現(xiàn)設(shè)置ff與ie元素絕對(duì)位置的方法。分享給大家供大家參考,具體如下:
function Show_menu(liid,divid){ var li=document.getElementById(liid); var div=document.getElementById(divid); div.style.left=getLeft(li)+140+'px'; div.style.top= getTop(li)+'px'; var tt=div.style.top; div.style.display='block'; alert(tt);}function getTop(e){ //用遞歸方法取值 var offset=e.offsetTop; if(e.offsetParent!=null) offset+=getTop(e.offsetParent); return offset;}function getLeft(e){ var offset=e.offsetLeft; if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); return offset;}更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript查找算法技巧總結(jié)》、《JavaScript動(dòng)畫特效與技巧匯總》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注