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焦点问题有什么解决方案吗