Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript iOS Safari-聚焦窗口_Javascript_Jquery_Html_Ios_Mobile Safari - Fatal编程技术网

Javascript iOS Safari-聚焦窗口

Javascript iOS Safari-聚焦窗口,javascript,jquery,html,ios,mobile-safari,Javascript,Jquery,Html,Ios,Mobile Safari,我有一个,它有一个简单的div,带有一个jQuery点击处理程序: <div class="testDiv" data-target="http://www.stackoverflow.com" data-open="false"> </div> $(document).ready(function(){ var newWindow; $('.testDiv').on('click', function(e){ var t

我有一个,它有一个简单的
div
,带有一个jQuery点击处理程序:

<div class="testDiv" 
   data-target="http://www.stackoverflow.com" 
   data-open="false">
</div>

$(document).ready(function(){
    var newWindow;
    $('.testDiv').on('click', function(e){
        var target = $(this).data('target');
        var open = $(this).data('open');

        if (!open){
            $(this).data('open','true');
            newWindow = window.open(target);
        }
        else {
            if (newWindow.closed){
                newWindow = window.open(target);
            }
            newWindow.focus();
        }
    });
})

$(文档).ready(函数(){
新窗口;
$('.testDiv')。在('click',函数(e)上{
var target=$(this.data('target');
var open=$(this.data('open');
如果(!打开){
$(this.data('open','true');
newWindow=window.open(目标);
}
否则{
if(newWindow.closed){
newWindow=window.open(目标);
}
newWindow.focus();
}
});
})
div
上的单击处理程序用于在尚未打开的情况下打开新窗口;如果它是打开的,它会提供窗口焦点。这在Win 7 x64上的Chrome上运行良好,但在iOS 8.3的Safari(在iPhone 6上)上,一旦窗口打开,单击
div
不会将焦点切换到打开的窗口。你必须关闭窗口并再次打开它才能获得焦点

这个iOS Safari焦点问题有什么解决方案吗