javascript使用遇到问题!! 本帖最后由 egeg3000 于 2009-08-20 22:54:02 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id=Idai class="paper" "style="position:absolute;z-index=1" onmousedown="getFocus(this)"> <div id=Idai class="paper" "style="position:absolute;z-index:1" onmousedown="getFocus(this)"></div> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">//-- 控制层移动start of script -->var Obj='';var index=10000;//z-index;document.onmouseup=MUpdocument.onmousemove=MMovefunction MDown(Object){ Obj=Object.id; document.all(Obj).setCapture(); pX=event.x-document.all(Obj).style.pixelLeft; pY=event.y-document.all(Obj).style.pixelTop;}function MMove(){ if(Obj!=''){ document.all(Obj).style.left=event.x-pX; document.all(Obj).style.top=event.y-pY; }}function MUp(){ if(Obj!=''){ document.all(Obj).releaseCapture(); Obj=''; }}//-- 控制层移动end of script -->//获得焦点;function getFocus(obj){ if(obj.style.zIndex!=index) { index = index + 2; var idx = index; obj.style.zIndex=idx; //obj.nextSibling.style.zIndex=idx-1; }}</script></head><body style=" margin:0px;"> <!-- body默认是有margin值的,你没有把这个数值计算在其中。 --><div id=Idai class='paper' style='position:absolute; border:#000000 1px solid; margin-left:20px; margin-top:20px;' onmousedown='getFocus(this)'><table> <tr> <td style='cursor:move;' width='93%' height='36px' onmousedown=MDown(Idai)>test</td> </tr></table></div></body></html> pixelTop和top这二个的问题,统一使用style.top吧,不过格式是 style.top=100+"px" 请问大侠怎么改本人JavaScript菜鸟 删了是可以,但是我的css布局也就都乱了,不能这样弄,杀鸡取卵 我试了一下用parseInt强行转换的方法,结果漂移变成了向上漂移了费解 你有测试我的代码吗?在5楼。如果不想改margin值,就在判断的时候加上这个值。 试过,不行,最后给最外层加宽度为1的白色边框解决的问题,那个貌似是css盒模型的bug。 请教 关于EXT RowEditor获取选中单元格 按浏览器的刷新和地址栏回车有什么区别? js绑定istbox WScript.Sleep没有作用? js实现打印时为什么第一次打印的都没有样式(CSS)? 问题 问一个简单的取值问题(在线等) 在javascript里点击右上角的"X"是什么事件? 我用的是2000SERVER+IIS,ASP页面有点问题,请高手指教 如何拿到动态对象的value [向大家提问]Function.prototype.apply.apply是什么东东??有分会补上~ 怎么利用JS创建一个text控件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
//-- 控制层移动start of script -->
var Obj='';
var index=10000;//z-index;
document.onmouseup=MUp
document.onmousemove=MMovefunction MDown(Object){
Obj=Object.id;
document.all(Obj).setCapture();
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}function MMove(){
if(Obj!=''){
document.all(Obj).style.left=event.x-pX;
document.all(Obj).style.top=event.y-pY;
}
}function MUp(){
if(Obj!=''){
document.all(Obj).releaseCapture();
Obj='';
}
}
//-- 控制层移动end of script -->
//获得焦点;
function getFocus(obj)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
//obj.nextSibling.style.zIndex=idx-1;
}
}</script>
</head><body style=" margin:0px;"> <!-- body默认是有margin值的,你没有把这个数值计算在其中。 -->
<div id=Idai class='paper' style='position:absolute; border:#000000 1px solid; margin-left:20px; margin-top:20px;' onmousedown='getFocus(this)'>
<table>
<tr>
<td style='cursor:move;' width='93%' height='36px' onmousedown=MDown(Idai)>test</td>
</tr>
</table>
</div>
</body>
</html>
如果不想改margin值,就在判断的时候加上这个值。