IE中的OffsetLeft和OffsetTop问题 [英] OffsetLeft and OffsetTop issue in IE

查看:175
本文介绍了IE中的OffsetLeft和OffsetTop问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE中面对offsetLeft和offsetTop问题,同时尝试创建一个工具提示,这将在每次点击日历上的不同事件时创建。以下是为Firefox工作的代码,但为IE创建问题。可以告诉我这个解决方案。

Facing offsetLeft and offsetTop problem in IE while trying to create one tooltip which will create each time when we click on different events on calendar.. the following is the code which will work good for firefox but creating problem for IE. can tell me the solution for this..

var ttip = __createElement("div","ttipbox","ttipbox"); //creating div
target = document.getElementById("sDiv"+ndiv); //taking the object of event on click of it tooltip has to display.

var x = target.offsetLeft ;
var y = target.offsetTop - (currObj.childNodes[2].childNodes[0].childNodes[1].scrollTop + ttip.offsetHeight); 
ttip.style.top= y+15;
ttip.style.left= x - 80;
ttip.style.zIndex= "2000";

提前感谢

推荐答案

应该有助于:

var obj = target.getBoundingClientRect();
var left = obj.left;
var top = obj.top;

这篇关于IE中的OffsetLeft和OffsetTop问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆