拖动的脚本 拖拉js,让表格在页面上可以托动
2006-02-25 13:31
274 查看
拖动的脚本 拖拉js,让表格在页面上可以托动
<SCRIPT LANGUAGE="JavaScript">
<!--
var currentMoveObj = null; //当前拖动对象
var relLeft; //鼠标按下位置相对对象位置
var relTop;
function f_mdown(obj)
{
currentMoveObj = obj; //当对象被按下时,记录该对象
currentMoveObj.style.position = "absolute";
relLeft = event.x - currentMoveObj.style.pixelLeft;
relTop = event.y - currentMoveObj.style.pixelTop;
}
window.document.onmouseup = function()
{
currentMoveObj = null; //当鼠标释放时同时释放拖动对象
}
function f_move(obj)
{
if(currentMoveObj != null)
{
currentMoveObj.style.pixelLeft=event.x-relLeft;
currentMoveObj.style.pixelTop=event.y-relTop;
}
}
//-->
</SCRIPT>
<BODY>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:50;top:50" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
<TD bgcolor="#CCCCCC" align="center" style="cursor:move">title1</TD>
</TR>
<TR>
<TD align="center" height="60">content</TD>
</TR>
</TABLE>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:350;top:250" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
<TD bgcolor="#CCCCCC" align="center" style="cursor:move">title2</TD>
</TR>
<TR>
<TD align="center" height="60">content</TD>
</TR>
</TABLE>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var currentMoveObj = null; //当前拖动对象
var relLeft; //鼠标按下位置相对对象位置
var relTop;
function f_mdown(obj)
{
currentMoveObj = obj; //当对象被按下时,记录该对象
currentMoveObj.style.position = "absolute";
relLeft = event.x - currentMoveObj.style.pixelLeft;
relTop = event.y - currentMoveObj.style.pixelTop;
}
window.document.onmouseup = function()
{
currentMoveObj = null; //当鼠标释放时同时释放拖动对象
}
function f_move(obj)
{
if(currentMoveObj != null)
{
currentMoveObj.style.pixelLeft=event.x-relLeft;
currentMoveObj.style.pixelTop=event.y-relTop;
}
}
//-->
</SCRIPT>
<BODY>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:50;top:50" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
<TD bgcolor="#CCCCCC" align="center" style="cursor:move">title1</TD>
</TR>
<TR>
<TD align="center" height="60">content</TD>
</TR>
</TABLE>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:350;top:250" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
<TD bgcolor="#CCCCCC" align="center" style="cursor:move">title2</TD>
</TR>
<TR>
<TD align="center" height="60">content</TD>
</TR>
</TABLE>
</BODY>
相关文章推荐
- 可以让表格变为拖动边界调整列宽度的JS办法
- 页面嵌入js文件就可以出现可拖动的悬浮球
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- 用js在当前页面增加一个表格
- JS实现表格行拖动
- 大家都可以拖动的web小方块——Node.js摸石头系列之七
- 注册js脚本到aspx前台页面
- jQuery锁定表格行列的js脚本,非CSS方法
- js脚本屏蔽页面点击
- 利用JS实现可以自由拖拽调整宽度的表格
- 如何使用js在页面中绘制表格
- js完成页面表格的增删
- 一个模仿图片透明渐变做的表格颜色渐变效果 js脚本特效
- JS获取web页面表格数据
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 自己写了自动跳转到指定页面的js小脚本,分享一下