JavaScript 打开模态窗口

/*
*打开模态窗口
*url 链接地址
*width 长度
*height 高度
*/
function openDiaWin(url, width, height) {
    var x = parseInt(screen.width / 2.0) - (width / 2.0);
    var y = parseInt(screen.height / 2.0) - (height / 2.0);
    var isMSIE = (navigator.appName == "Microsoft Internet Explorer");  //判断浏览器
    url = url.indexOf("?") == -1 ? url + "?rad=" + Math.random() : url + "&rad=" + Math.random();
    width = !width ? 500 : width;
    height = !height ? 400 : height;
    if (isMSIE) {
        return window.showModalDialog(url, window, "dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogLeft:" + x + "px; dialogTop:" + y + "px; status:no; directories:yes;scrollbars:no;Resizable=no; ");
    }
    else {
        return window.open(url, "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,modal=yes,width=" + width + ",height=" + height + ",resizable=no");

    }
    return false;   
}

 

 

posted @ 2012-12-03 07:45  Damon201611  阅读(251)  评论(0编辑  收藏  举报