不确定我在这里做错了什么。在父窗口中,我有:
$(document).ready(function() {
$('a.new-window').click(function(){
var posY = ($(window).height()-550)/2;
var posX = ($(window).width())/2;
window.open(this.href, this.alt, "toolbar=0,location=0,directories=0,scrollbars=1,screenX="+posX+",screenY="+posY+",status=0,menubar=0,width=550,height=550");
setTimeout('new-window.focus()', 1);
return false;
});
and so on.....
然后在子窗口我有:
<script type="text/javascript">
var window_focus;
$(window).focus(function() {
window_focus = true;
})
.blur(function() {
window_focus = false;
});
$(document).one('ready',function() {
setInterval(function() { $('body').append('has focus? ' + window_focus + '<br>'); }, 1000);
});
</script>
检查孩子的forcus。 “未定义”是我从孩子身上得到的。
我做错了什么?
答案 0 :(得分:1)
尝试:
$(document).ready(function() {
$('a.new-window').click(function(){
var posY = ($(window).height()-550)/2;
var posX = ($(window).width())/2;
var new_window = window.open(this.href, this.alt, "toolbar=0,location=0,directories=0,scrollbars=1,screenX="+posX+",screenY="+posY+",status=0,menubar=0,width=550,height=550");
setTimeout(function() {
new_window.focus();
}, 1);
return false;
});