【发布时间】:2017-03-14 08:46:13
【问题描述】:
我想将焦点保持在新的弹出窗口中,并避免用户单击父窗口,除非弹出窗口关闭。每次单击链接时,我下面的代码都将重点放在弹出窗口上。我想在每次打开时都将焦点放在弹出窗口上。
下面是我的html代码。
function PopupCenter(url, title, w, h) {
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
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 left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
<a href="" class="btn btn-outline btn-info btn-xs" onClick="PopupCenter('transfer.php?id=<?php echo $putIn;?>','xtf','980','350');">Transfer</a>
【问题讨论】:
标签: javascript html popup