$("#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 });
        }
    })




 

 

posted on 2017-02-04 10:32  cxd1008  阅读(234)  评论(0编辑  收藏  举报