| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 650 人关注过本帖
标题:怎样判断一个单元格在网页中的位置??
只看楼主 加入收藏
authorboy
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-3-13
收藏
 问题点数:0 回复次数:3 
怎样判断一个单元格在网页中的位置??
不知道在网页中有没有坐标系,如果有,该怎样确定一个元素(比如一表格的某一单元格)的坐标??急,请高手帮帮忙.
搜索更多相关主题的帖子: 单元格 网页中 位置 判断 坐标 
2007-04-13 15:55
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
JavaScript里可以

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-04-13 16:03
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
获取单元格坐标

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>获取单元格坐标</title>
<script language="javascript">
<!--
function getCoordinate(obj){
var top = obj.offsetTop;
var left = obj.offsetLeft;
alert("X:"+ left +",Y:"+ top)
}
//-->
</script>
</head>

<body style="margin:0px;">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" onclick="getCoordinate(this)">&nbsp;</td>
<td width="20%" onclick="getCoordinate(this)">&nbsp;</td>
<td width="20%" onclick="getCoordinate(this)">&nbsp;</td>
<td width="20%" onclick="getCoordinate(this)">&nbsp;</td>
<td width="20%" onclick="getCoordinate(this)">&nbsp;</td>
</tr>
<tr>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
</tr>
<tr>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
</tr>
<tr>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
</tr>
<tr>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
</tr>
<tr>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
<td onclick="getCoordinate(this)">&nbsp;</td>
</tr>
</table>

</body>
</html>

[此贴子已经被作者于2007-4-13 16:59:16编辑过]


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-04-13 16:58
authorboy
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-3-13
收藏
得分:0 
谢谢阳光,不知你给的代码中的坐标系的原点相对什么而言,是网页还是表格的左上角??
我是想打开网页后自动获得一单元格的坐标值,然后将其赋给一变量,我又该怎样做呢??
我是新手,请阳光再一帮下!!
2007-04-13 17:15
快速回复:怎样判断一个单元格在网页中的位置??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014290 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved