如何像alert()一样聚焦窗口/标签? [英] How to focus window/tab like alert()?

查看:95
本文介绍了如何像alert()一样聚焦窗口/标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在我的某些标签中执行了alert(),则会立即选中此标签。问题是 - 这个警报()框很难看。我用我的设计创建了所有..但是当我调用它时 - 选项卡没有被选中/聚焦。
window.focus();不起作用。任何想法?

If in some of my tabs alert() is executed, then this tab becomes selected instantly. The thing is - this alert() box is ugly. I have created with my design and all.. But when I call it - tab is not selected/focused. window.focus(); does not work. Any ideas?

推荐答案

您无法可靠地强制窗口或标签抓取焦点。有些浏览器比其他浏览器更容易理解:IE通常会允许它,但Firefox必须由用户配置才能允许它,而Safari基本上永远不会尊重焦点请求。 (好吧,几乎没有。)

You cannot reliably force windows or tabs to grab focus. Some browsers are more amenable to the idea than others: IE will generally allow it, but Firefox has to be configured by the user to allow it, and Safari will basically never honor a focus request. (Well, almost never.)

这篇关于如何像alert()一样聚焦窗口/标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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