获取鼠标坐标 弹窗位置

  作者:chrispy

infoDivXY(event,'.pop-tel-list',true);//获取鼠标坐标弹窗位置functioninfoDivXY(event,div,isHide){if(!isHide){$('.info-div').hide();}varinfoDiv=$(div);varinfoDivHeight=$(div).height();varinfoDivWidth=$(div).width();varwinHeight=$(window

infoDivXY(event,'.pop-tel-list',true); //获取鼠标坐标 弹窗位置

function infoDivXY (event,div,isHide){

    if(!isHide){

        $('.info-div').hide();

    }    

    var infoDiv = $(div);

    var infoDivHeight = $(div).height();

    var infoDivWidth = $(div).width();    

    var winHeight = $(window).height();

    var winWidth = $(window).width();

    var pointX = event.pageX;

    var pointY = event.pageY;

    var gdHeight = 0;

    if(url.indexOf('commissionCase.html') > -1){

        gdHeight = 240;

    }

    infoDiv.fadeIn();

    infoDiv.css({'left':pointX});

    if(winHeight - pointY + gdHeight > infoDivHeight){

        infoDiv.css({'top':pointY});

        if(winWidth - pointX < infoDivWidth){

            infoDiv.css({'bottom':'','top':pointY,'left':'','right':winWidth - pointX})

            return false;

        }

    }else{

        infoDiv.css({'top':'','bottom':winHeight - pointY});

        if(winWidth - pointX < infoDivWidth){

            infoDiv.css({'top':'','left':'','right':winWidth - pointX})

            return false;

        }

    }

}


有用  |  无用

猜你喜欢