将弹出窗口从背景移动到前景



我用下面的代码打开一个弹出窗口:

$('a[href^="/foto/"]').live ('click', function (e)
{
    e.preventDefault ();
    // open popup
    window.open (
        $(this).attr ('href'),
        'imgPreview',
        'width=1050,height=902,scrollbars=yes,menu=yes,toolbar=no'
    );
});

这段代码按预期工作,但如果弹出窗口是在后台,我点击另一个链接开始/foto/,弹出窗口停留在后台。因此,有可能没有意识到照片已经显示在弹出窗口中。

是否有可能移动照片弹出从背景到前景,如果我点击一个链接?

据我所知,window.focus()可以做到这一点:

$('a[href^="/foto/"]').live ('click', function (e)
{
    e.preventDefault ();
    // open popup
    var win=window.open (
        $(this).attr ('href'),
        'imgPreview',
        'width=1050,height=902,scrollbars=yes,menu=yes,toolbar=no'
    );
    win.focus();
});

最新更新