华赐软件 Bootstrap3

JS弹框

JS:

View Code
/*************************Begin弹出框*******************************/

///显示弹出框
///参数: url:url 地址,title:标题,width:宽度,height:高度
var isFirstPop = true;
var isIE6 = isIE6();
function showDiv(url, title, width, height) {
    //第一次运行时加载弹框
    if (isFirstPop == true) {
        loadShowDiv();
        isFirstPop = false;
    }

    //当前页面 Url(用作BackUrl参数)
    $("#hidBackUrl").val(document.location);

    //获取上下的宽度和高度
    var sw = document.documentElement.clientWidth;
    var sh = document.documentElement.clientHeight;
    //sh = isIE6 ? sh - 30 : sh;
    //sw = isIE6 ? sw - 200 : sw;
    //alert(sw);
    var lw = (sw - width) / 2 - 110 + "px";
    var th = (sh - height) / 2 - 22 + "px";
    //设置页面的上和左侧的距离
    $("#DialogDiv").css("top", th);
    $(".popUpWrap").css("left", lw);
    // 设置背景的宽和高
    $("#BgDiv").css({ display: "block", height: sh, width: sw });
    $("#BgDiv").css({ _height: "1000px" });
    //设置框架的浏览的Url地址
    $("#iframe").attr("src", url);
    var yscroll = document.documentElement.scrollTop;
    $(".popUpWrap").css("width", width);
    $(".popUpWrap").css("overflow", "hidden");
    $(".popUpCont01").css("width", width);
    $(".popUpCont02").css("height", height);
    $("#DialogDiv").css("display", "block");
    document.documentElement.scrollTop = 0;
    $("#title").html(title);
}
//加载弹出框
function loadShowDiv() {
    var div = document.createElement("div");
    div.setAttribute("id", "bgdivPop");
//    div.setAttribute("style", "position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;");

//    var obj = document.createElement("iframe");
//    obj.setAttribute("id", "iframeDiv");
//    obj.setAttribute("hspace", 0);
//    obj.setAttribute("frameborder", 0);
//    obj.setAttribute("vspace", 0);
//    obj.setAttribute("height", "100%");
//    obj.setAttribute("width", "100%");
//    obj.setAttribute("style", "position:absolute;_position:none;left:0;top:0;z-index:10;background:#ededed;");

    var obj2 = document.createElement("div");
    obj2.setAttribute("id", "DialogDiv");
    obj2.setAttribute("style", "display:none");

    var obj1 = document.createElement("div");
    obj1.setAttribute("id", "BgDiv");
//    obj1.appendChild(obj);

    div.appendChild(obj1);
    div.appendChild(obj2);

    document.body.appendChild(div);
    var val = getShowDiv();
    document.getElementById("DialogDiv").innerHTML = val;
    $("#btnClose").click(function () {
        //        closeShowDiv();
        $('#_my97DP', parent.document).css("display", "none");
        $("#BgDiv").css("display", "none");
        $("#DialogDiv").css("display", "none");
    });

}


//关闭div不刷新
function closeShowDiv() {
                var dd = parent.document.getElementById("BgDiv")
                var divb = parent.document.getElementById("DialogDiv")
                $(dd).css("display", "none")
                $(divb).css("display", "none")
    }
//关闭弹出框
//url:父页面
//当在自定义按钮上调用时需要传入url。弹出框自带的关闭图标不需要传
function closeDivAndReflash(url) {
    if (url == undefined) {
        url = $("#hidBackUrl").val();
        window.parent.showcontent.location.href = url;
    } else {
        window.parent.location.href = url;
    }
}
//弹出窗口内容
function getShowDiv() {
    var popContent = "";
    popContent += "<div class='clearfix popUpWrap'>"
    popContent += "<div class='popUpTitleRight'></div>"
    popContent += "<div class='popUpTitleLeft'></div>"
    popContent += "<div class='popUpTitleH3'></div>"
    popContent += "<div class='popUpCont'>"
    popContent += "<div class='popUpCont01'>"
    popContent += "<div class='popUpCont02'>"
    popContent += "<div class='clearfix titleDivCss'>"
    popContent += "<h3 class='fr TitleClose'><a href='#' id='btnClose'></a></h3>"
    popContent += "<input type='hidden' id='hidBackUrl'>";
    popContent += "<div class='fl TitleInfo' id='Strtitle' style=''><span class='iconTitle01'></span><span id='title'></span></div></div>"
    popContent += "<div class='contMiddle' style=''>"
    popContent += "<iframe name='' id='iframe' class='Megalab_Class_main_right_iframe' marginwidth='0' marginheight='0' hspace='0' height='100%' width='100%' vspace='0' frameborder='0' scrolling='auto'  style='*position:absolute;'>"
    popContent += "</iframe>"
    popContent += "</div></div></div></div>"
    popContent += "<div class='popUpBottRight'></div>"
    popContent += "<div class='popUpBottLeft'></div>"
    popContent += "<div class='popUpBottMiddle'></div>"
    popContent += "</div>"
    return popContent;
}
/*************************End弹出框*******************************/

HTML:

View Code
var url = '@Url.Content("~/UserManage/NewUser?method=adduser")';
                showDiv(url, '@ViewBag.New', 680, 483);

 

posted @ 2012-12-12 09:08  OpenCsharp.Net  阅读(285)  评论(0编辑  收藏  举报
华赐软件 Bootstrap3
w.huacisoft.com">华赐软件 Bootstrap3