获取控件在运行时于屏幕中的位置
下面Javascript是获取控件在运行时于屏幕中的位置:
你可以复制以下Javascript代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
function GetScreenPosition(object) { var position = {}; position.x = object.offsetLeft; position.y = object.offsetTop; while (object.offsetParent) { position.x = position.x + object.offsetParent.offsetLeft; position.y = position.y + object.offsetParent.offsetTop; if (object == document.getElementsByTagName("body")[0]) { break; } else { object = object.offsetParent; } } return position; }