---
title: "JAVAScript得到控件的坐标"
author: "renyanwei"
date: "2008-11-27T20:42:03Z"
tags: []
categories: ["企业架构"]
slug: "javascript"
draft: false
lastmod: "2008-11-27T20:42:03Z"
id: 281218
url: "https://renyanwei.iteye.com/blog/281218"
---

```
function getAbsoluteHeight(ob){
         return ob.offsetHeight
}
function getAbsoluteWidth(ob){
     return ob.offsetWidth
}

     function getAbsoluteLeft(ob){
         var mendingLeft = ob .offsetLeft;
         while( ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY" ){
             mendingLeft += ob .offsetParent.offsetLeft;
             ob = ob.offsetParent;
         }
         return mendingLeft ;
     }
     function getAbsoluteTop(ob){
         var mendingTop = ob.offsetTop;
         while( ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY" ){
             mendingTop += ob .offsetParent.offsetTop;
             ob = ob .offsetParent;
         }
         return mendingTop ;
     }
```