网页浮动小窗口拖动功能【兼容火狐和ie6 测试通过】
2009-02-02 16:27
531 查看
onmousedown="divBlock_event_mousedown(arguments[0])"放在要拖动div的标签内
<script language="javascript">
function divBlock_event_mousedown(e) {
var e, obj, temp;
obj = document.getElementById("gonggao"); //要拖动的窗口ID
e = window.event ? window.event : e;
obj.startX = e.clientX - obj.offsetLeft;
obj.startY = e.clientY - obj.offsetTop;
document.onmousemove = document_event_mousemove;
temp = document.attachEvent ? document.attachEvent("onmouseup",
document_event_mouseup) : document.addEventListener("mouseup",
document_event_mouseup, "");
}
function document_event_mousemove(e) {
var e, obj;
obj = document.getElementById("gonggao");
e = window.event ? window.event : e;
with (obj.style) {
left = e.clientX - obj.startX + "px";
top = e.clientY - obj.startY + "px";
}
}
function document_event_mouseup(e) {
var temp;
document.onmousemove = "";
temp = document.detachEvent ? document.detachEvent("onmouseup",
document_event_mouseup) : document.removeEventListener("mouseup",
document_event_mouseup, "");
}
</script>
<script language="javascript">
function divBlock_event_mousedown(e) {
var e, obj, temp;
obj = document.getElementById("gonggao"); //要拖动的窗口ID
e = window.event ? window.event : e;
obj.startX = e.clientX - obj.offsetLeft;
obj.startY = e.clientY - obj.offsetTop;
document.onmousemove = document_event_mousemove;
temp = document.attachEvent ? document.attachEvent("onmouseup",
document_event_mouseup) : document.addEventListener("mouseup",
document_event_mouseup, "");
}
function document_event_mousemove(e) {
var e, obj;
obj = document.getElementById("gonggao");
e = window.event ? window.event : e;
with (obj.style) {
left = e.clientX - obj.startX + "px";
top = e.clientY - obj.startY + "px";
}
}
function document_event_mouseup(e) {
var temp;
document.onmousemove = "";
temp = document.detachEvent ? document.detachEvent("onmouseup",
document_event_mouseup) : document.removeEventListener("mouseup",
document_event_mouseup, "");
}
</script>
相关文章推荐
- css 固定表头 拖动滚动条时对应表头所对应的列 ie6测试通过
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- Js版Windows窗口模拟,兼容FF火狐,可拖动,可改变大小
- 坑爹的ie6--解决ie6下qq浮动窗口不兼容问题
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- 通过鼠标来拖动拉伸窗口,兼容当前主流浏览器。
- 在网页中插入FLV视频,经测试兼容IE、火狐、谷歌等浏览器
- 纯CSS定位的固定浮动层代码 不闪 兼容IE6 8 火狐 谷歌等
- 利用JQuery实现网页左侧树形菜单(IE6测试通过)
- 网页PNG透明支持(IE6、IE7、firefox下测试通过
- 利用JQuery实现网页左侧树形菜单(IE6 IE7 Firefox测试通过)
- 拖动DIV,兼容IE6-9,兼容遨游火狐等
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- 在网页上插入视频,兼容ie6,火狐,谷歌
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)