Jquery 实现弹出层插件

2020-05-17 06:27:24易采站长站整理


//根据传入数据,添加遮罩层,弹出提示框
    function xsMain(title, width, height, tag, close, mainContent) {
        var divmask = “<div class=”mask”></div>”;
        $(mainContent).append(divmask);
        var xsPop1 = ” <div id=”xsPop” class=”PopUp”> <div class=”PopHead” id=”xsPopHead”>”;
        var xsPop2 = ” <b>” + title + ” </b><span id=”xsColse”>” + close + “</span>”;
        var xsPop3 = ”  </div>  <div class=”PopMain” id=”xsPopMain”>”;
        var xsPop5 = “</div><span id=”xytest”></span> </div>”;
        var allHtml = xsPop1 + xsPop2 + xsPop3 + xsPop5;
        $(mainContent).append(allHtml);
        $(tag).show();
        $(tag).appendTo(“#xsPopMain”);
        //得到浏览器的高度和宽度,进行后面判断(高度超过,拖动边框限制)
        clientHeight = window.screen.height;
        clientWidth = window.screen.width;
        if (height > clientHeight) {
            height = clientHeight – 100;
        }
        if (width > clientWidth) {
            width = clientWidth – 100;
        }
        $(“#xsPop”).css({
            “heigth”: height + “px”,
            “width”: width + “px”,
            “margin-top”: “-” + (height / 2) + “px”,
            “margin-left”: “-” + (width / 2) + “px”
        });
        $(“#xsPopMain”).css(“height”, height – $(“#xsPopHead”).height());
        xsdrag(“#xsPopHead”, “#xsPop”); //绑定拖动动作