$window.focus() 在 iOS Safari 中的现有选项卡上不起作用 [英] $window.focus() doesn't work on existing tabs in iOS Safari

查看:60
本文介绍了$window.focus() 在 iOS Safari 中的现有选项卡上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我用 var win = window.open("", "name") 打开一个新窗口,然后使用 win.focus() 聚焦窗口时首次在 iOS Safari 中工作.

When I open a new window with var win = window.open("", "name") and then focus the window using win.focus() this works for the first time in iOS Safari.

但是当使用 window.open 通过名称再次引用现有窗口时,我无法在 iOS Safari 中再次聚焦.在 Chrome 中,这可以正常工作.

But when the existing window is referenced again by name using window.open I can't focus again in iOS Safari. In Chrome this works fine.

有什么方法可以让我只知道名称就可以专注于已经存在的标签?

Is there any way how I can focus on an already existing tab just knowing the name?

我创建了一个用于测试的小提琴:https://jsfiddle.net/szqnu38f/

I created a fiddle for testing: https://jsfiddle.net/szqnu38f/

推荐答案

这似乎是 iOS Safari 中的一个错误.

This seems to be a bug within iOS Safari.

通常,无法在现有命名选项卡上再次设置焦点.在打开选项卡后再次单击目标设置为名称的链接时也是这种情况 --> 参见 https://jsfiddle.net/g3bk1v5a/4/

Generally, it is not possible to set the focus again on an existing named tab. This is also the case when a link with target set to a name is clicked again after the tab was opened --> see https://jsfiddle.net/g3bk1v5a/4/

<a href="http://www.google.com" target="test">Test</a>

因此,我在 Apple 打开了一个错误报告.

Therefore, I opened a bug report at Apple.

这篇关于$window.focus() 在 iOS Safari 中的现有选项卡上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆