惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
C
Check Point Blog
M
MIT News - Artificial intelligence
T
The Blog of Author Tim Ferriss
Jina AI
Jina AI
博客园 - 【当耐特】
U
Unit 42
月光博客
月光博客
腾讯CDC
Y
Y Combinator Blog
小众软件
小众软件
博客园_首页
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
T
Tailwind CSS Blog

博客园 - 周末

JS判断IE6,ie7,ie8,ff ASP.NET(C#) 四舍五入、进一法、舍位(取整,舍去小数,向负无穷舍入)函数 在线用户统计的实现方法 HttpModule与HttpHandler详解 IE bug: 1像素的dotted/dashed边框 JS日期计算函数 同时兼容ie和ff的获取事件的方法 关于JS冒泡的问题 jQuery load()方法的美妙用法 CSS 使用expression方法优化 判断 iframe 是否加载完成的完美方法 setCapture,captureEvents,releaseCapture 的技巧。 经典左右两列布局CSS 准确取得当前滚动条的位置 不常用的有意思的标签:optgroup log4net的日志输出格式-log4net.Layout.PatternLayout用法 log4net 将日志按不同类型写入多个文件 FireFox使用技巧 vs2008.net多语言实现方法
兼容各主流浏览器的简单拖拽drag
周末 · 2009-09-24 · via 博客园 - 周末

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><style type='text/css'> 
#d
{border:1px solid green;width:90px;height:57px;position:absolute;} 
#h
{border:1px solid green;width:90px;height:17px;position:absolute;} 
</style> 
<script type='text/javascript' src="/js/jquery/jquery-1.2.6.min.js"></script>
<script type='text/javascript'> 
(
function($) {
    $.fn.extend({
        drag: 
function(id) {
            $(
this).mousedown(function(event) {
                
var Obj, pX,pY;
                document.onmouseup 
= MUp;
                document.onmousemove 
= MMove;
                MDown(id, event);
                
function MDown(id, event) {
                    Obj 
= document.getElementById(id);
                    
if (Obj.setCapture) 
                        Obj.setCapture();
                    
else 
                        window.captureEvents(Event.MOUSEMOVE 
| Event.MOUSEUP);
                    pX 
= event.clientX - Obj.offsetLeft;
                    pY 
= event.clientY - Obj.offsetTop;
                }
                
function MMove(event) {
                    
if (window.event) event = window.event;
                    
if (Obj) {
                        Obj.style.left 
= event.clientX - pX + "px";
                        Obj.style.top 
= event.clientY - pY + "px";
                    }
                }
                
function MUp(event) {
                    
if (Obj) {
                        
if (Obj.releaseCapture)
                                Obj.releaseCapture();
                        
else 
                            window.captureEvents(Event.MOUSEMOVE 
| Event.MOUSEUP);
                        Obj 
= null;
                    }
                }
            });
        }
    });
})(jQuery); 
</script> 
</head> 
<body> 
<div id="d"> 
<div id="h">Header</div> 
</div> <script type='text/javascript' > 
$(
"#h").drag('d'); //IE下,点击id='h'可拖动id='d',FF兼容待完善 
</script> 
</body>
</html>