var the = event.srcElement ;function getPosition( the )
{
var x = the.offsetWidth;
var y = the.offsetTop ;
var the2 = the ;
while( the2 && the2.offsetTop && the2.offsetWidth )
{
x += the2.offsetWidth ;
y += the2.offsetTop ;
the2 = the2.parentNode ;
}
}
{
var x = the.offsetWidth;
var y = the.offsetTop ;
var the2 = the ;
while( the2 && the2.offsetTop && the2.offsetWidth )
{
x += the2.offsetWidth ;
y += the2.offsetTop ;
the2 = the2.parentNode ;
}
}
解决方案 »
- Array二维数组问题
- 一个灰常灰常简单的js问题
- javascript的类中没有私有成员呀,对象的封装性如何保证呀?
- 运行JAVASCRPT 后。页面字体变大了。好奇怪!
- 請問JScript與JavaScript有什么不一樣嗎?
- 求救!~谢谢各位大哥
- 怎样让一个按钮初始时是不可用的,点击另一按钮后让他可用
- 请问这样做到一个框架,点击左窗口的连接,右窗口里的文本框里显示“你点击了按钮”
- 一般在点击文字时链接打开一个播放器播放。怎样用本页创建的播放器播放midi2.rmi?
- 通过cookie让下拉框值在提交后保持不变的问题。
- 怎么来控制输入的百分号一定要是全角?
- 请问大家,这个function是完成什么功能?
其实我要用的只是
var x = the.offsetLeft;
var y = the.offsetTop ;
offsetLeft和offsetTop是相对位置,相对父结点的位置.
如果你的链接不在顶层的话,则可能不准的