本文共 1197 字,大约阅读时间需要 3 分钟。
墨色风雨
单/双监控功能(贷记于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(我只想链接到这个页面,但万一这个网站掉了,代码就在这里了,干杯!)
转载地址:http://ehexl.baihongyu.com/