在网页里有一个iframe,iframe里的按钮被单击时,我想获得单击点相对于整个网页客户区的坐标,这个坐标用来确定另一个iframe的显示位置(这个iframe用来动态显示信息)另外 iframe根据自己的内容动态的改变大小的代码
//'ifDetail'是iframe的名字
document.all['ifDetail'].style.height=ifDetail.document.body.scrollHeight;
能否写为公共的函数?当把ifDetail换成document.getElementById('ifDetail')时就不能正常显示了,对于document.all['ifDetail'],我也不太清楚这种形式和getElementById()得到的对象有什么区别,更换之后也不对请各位指教^-^
//'ifDetail'是iframe的名字
document.all['ifDetail'].style.height=ifDetail.document.body.scrollHeight;
能否写为公共的函数?当把ifDetail换成document.getElementById('ifDetail')时就不能正常显示了,对于document.all['ifDetail'],我也不太清楚这种形式和getElementById()得到的对象有什么区别,更换之后也不对请各位指教^-^
解决方案 »
- 用js处理一段url
- 请问百度知道js中的utdata是怎么算出来的
- js能跟踪全屏幕的鼠标事件吗?
- javaScript比较两个日期是否相等
- 请教一个包含换行的正则表达式的书写。还请忙忙
- 高手帮忙:仿阿里巴巴的一个导航菜单的脚本,点击样式变化
- 网页中调用了一个网站的js文件,其中有CSS,影响到该网页的CSS样式,使我的页面乱了,如何解决?
- 紧急求助!!!!!
- 哪里有EMCAScript、JavaScript、JScript各个版本差异的对照表?
- My97DatePicker IE9中,格式yyyy-MM和yyyy年MM月,显示不正常
- 怎样用键盘控制光标?
- javascript 能把收到的二进制文件还原成图片并且显示在网页上么?
top.window.event.y
{
var tempstr = "frame1<scri"+"pt>function document.onclick(){alert(window.event.x + top.document.getElementById('frame1offsetx').value*1);alert(window.event.y + top.document.getElementById('frame1offsety').value*1);}</scr"+"ipt>";
window.frames.item("frame1").document.write(tempstr);
alert(window.frames.item("frame1").document.documentElement.innerHTML);
var iframe1 = document.getElementById("frame1");
var pos = getAbsolutePosition(iframe1);
document.getElementById("frame1offsetx").value = pos.x;
document.getElementById("frame1offsety").value = pos.y;
}function getAbsolutePosition(obj)
{
position = new Object();
position.x = 0;
position.y = 0;
var tempobj = obj;
while(tempobj!=null && tempobj!=document.body)
{
position.x += tempobj.offsetLeft + tempobj.clientLeft;
position.y += tempobj.offsetTop + tempobj.clientTop;
tempobj = tempobj.offsetParent
}
position.x += document.body.scrollLeft;
position.y += document.body.scrollTop;
return position;
}</script>
谢谢!
tempobj.clientLeft也加进来时什么意思呢?我查clientLeft的解释是这样的:
Retrieves the distance between the offsetLeft property and the true left side of the client area.看不明白