popup = window.open(thelink,'Facebook Share','resizable=1,status=0,location=0,
width=500,height=300');
我想将此窗口一直移动到中心(垂直和水平)
答案 0 :(得分:5)
Owalla,
我直接从谷歌搜索得到类似这个简单的javascript的东西,我们可以用更简单的方式在jquery中进行,但尝试这样的东西
var myWindow;
function openCenteredWindow(url) {
var width = 400;
var height = 300;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
myWindow = window.open(url, "subWind", windowFeatures);
}
答案 1 :(得分:2)
试试这个脚本
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
此处链接:http://www.nigraphic.com/blog/java-script/how-open-new-window-popup-center-screen