//点击事件失效
<div onclick="event.cancelBubble = true;">></div>
//拖动
$(function () {
var bool = false;
var offsetX = 0;
var offsetY = 0;
$("#topDivContent").mousedown(function () {
bool = true;
offsetX = event.offsetX;
offsetY = event.offsetY;
$(this).css('cursor', 'move');
})
.mouseup(function () {
bool = false;
})
$(document).mousemove(function (e) {
if (!bool)
return;
var x = event.clientX - offsetX;
var y = event.clientY - offsetY;
$("#topDivContent").css("left", x);
$("#topDivContent").css("top", y);
})
})
 
//other
document.body.onmousemove = function(e) {
if (!divDialog.dragging) return;
e = e || window.event;
var mouseX, mouseY;
var mouseOffsetX, mouseOffsetY;
if (e.pageX || e.pageY) {
mouseX = e.pageX;
mouseY = e.pageY;

} else {
mouseX =
e.clientX + document.body.scrollLeft -
document.body.clientLeft;
mouseY =
e.clientY + document.body.scrollTop -
document.body.clientTop;

}

divDialog.style.left = (mouseX - dialogWidth * 0.4) + "px";
divDialog.style.top = (mouseY - 10) + "px";
};
posted on 2011-09-06 22:07  小伟地方  阅读(4533)  评论(0编辑  收藏  举报