首页 > 网站 > WEB开发 > 正文

jquery之窗口拖动

2024-04-27 15:04:26
字体:
来源:转载
供稿:网友

   $("#showTitle").mousedown(function (e) {        vbool = true;        vHeight = e.pageY;        vWidth = e.pageX;        cHeight = vHeight - $("#show").offset().top;        cWdith = vWidth - $("#show").offset().left;        //alert("divshow" + $("#show").offset().top + " divvHeight" + vHeight);        //alert("高" + cHeight + " 宽" + cWdith);    })    $(document).mouseup(function () {        vbool = false;    })    var showWidth = $("#show").width();    var showHeight = $("#show").height();    var documentWidth = $(document).width();    var documentHeight = $(document).height();    $(document).mousemove(function (e) {        if (vbool) {            var divheight = e.pageY - cHeight;//窗口要移动到的位置            var divwidth = e.pageX - cWdith;//窗口要移动到的位置            $("#la1").text(divheight + "w" + divwidth + "win" + showWidth + " x " + documentWidth + "" + showWidth);            if (divwidth < 0) {                divwidth = 0;            }            if (divheight < 50) {                divheight = 50;            }            if (divwidth > documentWidth - showWidth) {                divwidth = documentWidth - showWidth - 5;            }            if (divheight > documentHeight - showHeight) {                divheight = documentHeight - showHeight - 5;            }            $("#show").CSS({ "left": divwidth, "top": divheight });        }    }) 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表