您的位置:首页 > Web前端 > JavaScript

JavaScript 打开模态窗口

2012-12-03 07:45 281 查看
/*
*打开模态窗口
*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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: