我尝试在 window.open 括号中使用宽度、高度、顶部和左侧参数,但无论我做什么,Javascript 弹出通知仍然保留在左上角。
有人可以帮忙吗?
function password() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password','Enter your password here');
while (testV < 3) {
if (!pass1)
history.go(0);
if (pass1.toLowerCase() == "test") {
/*alert('You Are Successful, Click To Continue!'); */
var targetWin = window.open('');
break;
}
testV+=1;
var pass1 =
prompt('Access Denied - Your Password Is Incorrect, Please Try Again.','Enter your
password here');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(0);
return "";
}
最佳答案
如果您尝试将 targetWin 居中,请尝试执行以下操作:
假设您的目标窗口大小为 485 x 700。
function openWindow(meh)
{
var x = screen.width/2 - 700/2;
var y = screen.height/2 - 450/2;
window.open(meh.href, 'sharegplus','height=485,width=700,left='+x+',top='+y);
}
var targetWin = openWindow(<url>);
关于javascript - 密码请求窗口不会在屏幕上居中 :(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16837218/