我想做成一个效果 就是进入页面的时候div层是 隐藏的 当 点击页面中一条记录的详细信息的时候 弹出来 居中 ,然后再标题的地方点击鼠标整个div层可以再 屏幕内拖动(注意是屏幕内哦,就是div 边框到屏幕边的时候就过不去了)。层可以很容易弹出来 但是怎么拖动 我真的不知道 求教啊 求教。。
解决方案 »
- 这个怎么办!
- GridView如何用javascript实现点击某一列某一单元格来编辑单元格?
- 求救:如何改写math.floor功能
- js窗口传值问题??????????????
- 想实现一个类似于CSDN -> FAQ列表页的渐变效果
- 难道真的没办法防止网页跳出框架??呜~~
- 如果在一个连接上点击后则将这个连接取消掉,怎么用javascript来实现呢??(在线等待)
- 那下面这部分代码是什么意思?是不是也是javascript调用WORD的?
- 在HTML文件中嵌入JSP,用来检测注册的各个项目的数据有效性,怎么做?
- 如何获取js生成内容的 完整的html代码
- 请大家帮我看看这段JS代码,很简单的IF语句,怎么完全无效呢
- 请教各位,利用 JS 导出(创建) word,速度太慢问题!
<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">
var colors=["yellow",'red','blue','black'];
function Test(){
this.move=0;
this.x=0;
this.y=0;
this.div=document.createElement("div");
this.div.style.width="200px";
this.div.style.height="200px";
this.div.style.left="100px";
this.div.style.top="100px";
this.div.style.position="absolute";
this.color=parseInt(Math.random()*colors.length);
this.div.style.backgroundColor=colors[this.color];
this.div.onmousedown=this.can_move.bind(this);
this.div.onmouseup=this.cannot_move.bind(this);
this.div.onmousemove=this.show_move.bind(this);
document.body.appendChild(this.div);
}
function add(){
new Test();
}
Test.prototype.can_move=function(e){
this.move=1;
var a=e||window.event;
var x0=a.clientX;
var y0=a.clientY;
this.x=parseInt(this.div.style.left)-x0;
this.y=parseInt(this.div.style.top)-y0;
}
Test.prototype.cannot_move=function(){
this.move=0;
}
Test.prototype.show_move=function(e){
var a=e||window.evevt;
var x0=a.clientX;
var y0=a.clientY;
if(this.move==1){
this.div.style.left=x0+this.x+"px";
this.div.style.top=y0+this.y+"px";
}
}
</script>
</head><body>
<input type="button" onclick="add()" value="add">
</body>
</html>
这样试试