java 弹出窗口在屏幕中心_屏幕上的弹出式窗口中央?

0a89f97ce45bf9f36163a305a1c23edc.png

墨色风雨

单/双监控功能(贷记于http://www.xtf.dk-谢谢!)更新:由于@Frost,它还能在不超过屏幕宽度和高度的窗口上工作!如果你在双显示器上,窗口会水平地集中,但不是垂直的.使用此函数对此进行解释。function PopupCenter(url, title, w, h) {

    // Fixes dual-screen position                         Most browsers      Firefox

    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;

    var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;

    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth :

     screen.width;

    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : 

    screen.height;

    var systemZoom = width / window.screen.availWidth;var left = (width - w) / 2 / systemZoom + dualScreenLeftvar top = (height - h) / 2 /

     systemZoom + dualScreenTop    var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w / systemZoom + ', height=' + 

     h / systemZoom + ', top=' + top + ', left=' + left);

    // Puts focus on the newWindow

    if (window.focus) newWindow.focus();}用法示例:PopupCenter('http://www.xtf.dk','xtf','900','500');贷记如下:http:/www.xtf.dk/2011/08/Center-新-弹出窗口-偶-on.html(我只想链接到这个页面,但万一这个网站掉了,代码就在这里了,干杯!)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值