拖动层效果
来源:互联网 发布:删除Mac本上的图片 编辑:程序博客网 时间:2024/05/16 06:13
很多网站都有这样一个功能,比如51job,它用的就是和这样差不多,当你点击一个事件时 它会弹出一个层,而这个层是可以拖动的,代码如下:
<html>
<head>
<style type="text/css">...
body {...}{
margin: 0px;
}
#div1 {...}{
display: block;
position: absolute;
z-index: 1000;
height: 100%;
width: 100%;
background: #000000;
filter:Alpha(opacity=30);
}
#div2 {...}{
display: block;
position: absolute;
height:10;
width: 600;
margin:200px 0px 0px 300px;
z-index: 1001;
}
#div3 {...}{
display: block;
position: absolute;
z-index: 999;
}
</style>
<script type="text/javascript">...
//定义移动对象和移动坐标
var Mouse_Obj="none",_x,_y;
//拖动对象函数(自动)
document.onmousemove=function()
...{
if(Mouse_Obj!=="none")
...{
document.getElementById(Mouse_Obj).style.left=_x+event.x;
document.getElementById(Mouse_Obj).style.top=_y+event.y;
event.returnValue=false;
}
}
//停止拖动函数(自动)
document.onmouseup=function()
...{
Mouse_Obj="none";
}
//确定被拖动对象函数 o为被拖动对象
function m(o)
...{
Mouse_Obj=o;
_x=parseInt(document.getElementById(Mouse_Obj).style.left)-event.x;
_y=parseInt(document.getElementById(Mouse_Obj).style.top)-event.y;
}
</script>
</head>
<body>
<div id="div1" style="display:none"></div>
<div id="div2" style="left: 0px;top: 0px;display:none " >
<table width="100%" border="0" cellpadding="3" cellspacing="1"
style="background: #ff7300;
position:static;filter:progid:DXImageTransform.Microsoft.DropShadow
(color=#666666,offX=4,offY=4,positives=true)" align="center">
<tr style="cursor: move;" onmousedown="m('div2')">
<td><font color="#FFFFFF">温馨提示:</font></td>
<td align="right"><input type="button" value="x"
onClick="document.getElementById
('div1').style.display='none';document.getElementById
('div2').style.display='none';" style="cursor: hand;"></td>
</tr>
<tr>
<td colspan="2" width="100%" bgcolor="#FFFFFF" height="150"
align="middle">欢迎访问 <a href="http://levon.51.com"
target="_blank">http://Levon.51.com</a></td>
</tr>
</table>
</div>
<div id="div3"><input type="button" value="打开层"
onClick="document.getElementById
('div1').style.display='block';document.getElementById
('div2').style.display='block';"></div>
</body>
</html>
<head>
<style type="text/css">...
body {...}{
margin: 0px;
}
#div1 {...}{
display: block;
position: absolute;
z-index: 1000;
height: 100%;
width: 100%;
background: #000000;
filter:Alpha(opacity=30);
}
#div2 {...}{
display: block;
position: absolute;
height:10;
width: 600;
margin:200px 0px 0px 300px;
z-index: 1001;
}
#div3 {...}{
display: block;
position: absolute;
z-index: 999;
}
</style>
<script type="text/javascript">...
//定义移动对象和移动坐标
var Mouse_Obj="none",_x,_y;
//拖动对象函数(自动)
document.onmousemove=function()
...{
if(Mouse_Obj!=="none")
...{
document.getElementById(Mouse_Obj).style.left=_x+event.x;
document.getElementById(Mouse_Obj).style.top=_y+event.y;
event.returnValue=false;
}
}
//停止拖动函数(自动)
document.onmouseup=function()
...{
Mouse_Obj="none";
}
//确定被拖动对象函数 o为被拖动对象
function m(o)
...{
Mouse_Obj=o;
_x=parseInt(document.getElementById(Mouse_Obj).style.left)-event.x;
_y=parseInt(document.getElementById(Mouse_Obj).style.top)-event.y;
}
</script>
</head>
<body>
<div id="div1" style="display:none"></div>
<div id="div2" style="left: 0px;top: 0px;display:none " >
<table width="100%" border="0" cellpadding="3" cellspacing="1"
style="background: #ff7300;
position:static;filter:progid:DXImageTransform.Microsoft.DropShadow
(color=#666666,offX=4,offY=4,positives=true)" align="center">
<tr style="cursor: move;" onmousedown="m('div2')">
<td><font color="#FFFFFF">温馨提示:</font></td>
<td align="right"><input type="button" value="x"
onClick="document.getElementById
('div1').style.display='none';document.getElementById
('div2').style.display='none';" style="cursor: hand;"></td>
</tr>
<tr>
<td colspan="2" width="100%" bgcolor="#FFFFFF" height="150"
align="middle">欢迎访问 <a href="http://levon.51.com"
target="_blank">http://Levon.51.com</a></td>
</tr>
</table>
</div>
<div id="div3"><input type="button" value="打开层"
onClick="document.getElementById
('div1').style.display='block';document.getElementById
('div2').style.display='block';"></div>
</body>
</html>
- 拖动层效果
- DIV拖动层效果
- jQuery 模块拖动,拖动层效果
- js 拖动层效果[实例]
- JavaScript:Div层拖动效果
- js 实现拖动层效果
- flash效果展开层、关闭层,并且可以拖动层。
- AJAX实现的层拖动效果
- 拖动层效果,兼容IE和FF!
- 可拖动的弹出层提示效果
- 可拖动的弹出层提示效果
- 可拖动的弹出层提示效果
- 鼠标可拖动的浮动层效果
- js动态效果拖动层排序
- JS弹出并拖动层效果
- JS_拖动_一个封装好的拖动层效果
- js鼠标拖动层/层的移动和浮动效果
- JavaScript 拖放(拖拽、拖动)层效果(程序原理+深度分析)
- Silverlight 1.1正式更名为Silverlight 2.0
- 取到服务器时间的JS脚本给客户端显示时间
- Windows Mobile 打包过程
- 最小化程序到托盘,并且有右键菜单!
- TCP/IP学习笔记之六 --- ICMP: Internet控制报文协议
- 拖动层效果
- Aruba推出新一代超高性能多业务移动控制器和802.11n接入点
- Linux环境下的Socket编程
- virtual pc 2007(vpc2007) 使用中无法显示控制主界面的解决方法
- Oracle的RBO和CBO优化
- php 常用学习站点
- Window Mobile 打包过程2
- 消息队列(Message Queue)简介及其使用
- Jsp/Java代码分离.实现页面真正的代码分离 测试代码是否按想法运行,下载原代码