js open() 与showModalDialog()方法

此方法可通用,项目开发中经常要用到:

//w:宽,h:高,url:地址,tag:标记
function showWin(w, h, url, tag) {
 var t = (screen.height - h) / 2; //离顶部距离
 var l = (screen.width - w) / 2; //离左边距离
 window.open(url, tag, "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",location=0");
}
//路径地址,window对象,宽,高
function open_Dialog(url, win, Width, Height) {
    var return_Value;
    var iTop2 = (window.screen.availHeight - 20 - Height) / 2;
    var iLeft2 = (window.screen.availWidth - 10 - Width) / 2;
    var height2 = Height;
    var mytime = new Date().toLocaleTimeString();
    var newUrl = url + '&time=' + mytime;
    if (document.all && window.print) {
        if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
            height2 = Height + 30;
            return_Value = window.showModalDialog(newUrl, win, "dialogLeft:" + iLeft2 + "px;dialogTop:" + iTop2 + "px;dialogWidth:" + Width + "px;dialogHeight:" + height2 + "px;center:yes;status:no;scroll:no;help:no;");
        }
        else {
            return_Value = window.showModalDialog(newUrl, win, "dialogLeft:" + iLeft2 + "px;dialogTop:" + iTop2 + "px;dialogWidth:" + Width + "px;dialogHeight:" + Height + "px;center:yes;status:no;scroll:no;help:no;");
        }
    }
    else {
        window.open(newUrl, win, "top=" + iTop2 + ",left=" + iLeft2 + ",width=" + Width + "px,height=" + height2 + "px,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no,status=no");
    }
}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邹琼俊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值