window.focus(),self.focus()无法在firefox中运行 [英] window.focus(), self.focus() not working in firefox

查看:194
本文介绍了window.focus(),self.focus()无法在firefox中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我正在开发一个聊天应用程序...我有多个聊天窗口...我想知道哪个windw包含新消息...我有以下代码..

Hi all i am developing a chat application ... i have multiple chat windows ... i want to know which windw contain new message ... i have the following code ..

function getCount()
{
    $.ajax({
       type: "POST",
       url: baseUrl + '/Chat/count',
       data: "chat_id=" + document.ajax.chat_id.value,
       success: function(msg){
                if(msg == 'new1') {
                    self.focus();
                                            //window.focus();

                }
            }
    });
}

如果操作员同时参加聊天....

If an operator attending both chat....

例如,网址类似于
http: // localhost / nisanth / admin / Chat / index / chatId / 15
http:// localhost / nisanth / admin / Chat / index / chatId / 16

http:// localhost / nisanth / user / Chat / index / chatId / 15
http:// localhost / nisanth / user / Chat / index / chatId / 16

如果用户16 输入我需要关注的消息

if the user 16 enter a message i need focus

http://localhost/nisanth/admin/Chat/index/chatId/16

这段代码可以正常使用IE而不是在Firefox中...请给我一个解决方案...上面的代码是在相同的HTML中

This code is work fine with IE but not in firefox...please give me a solution... the above code is in the same html

推荐答案

如果设置了安全选项,Firefox将仅服从提升窗口的请求,并且默认情况下不设置。据我所知,Chrome根本不会关注focus()请求。 Safari确实服从focus()请求。

Firefox will only obey requests to raise a window if a security option is set, and it's not set by default. Chrome won't pay attention to focus() requests at all, as far as I can tell. Safari does obey focus() request.

特定的Firefox设置位于工具 - >选项(Linux上的编辑 - >首选项,也许是MacOS)对话框。有一个内容选项卡,其中有一个用于启用Javascript的复选框。除了 是一个高级按钮,它会显示另一个对话框,其中一个复选框可以通过页面代码找到允许(或禁止)窗口升高和降低的复选框。

The specific Firefox setting is in the "Tools" -> "Options" ("Edit -> Preferences" on Linux, maybe MacOS) dialog. There's a "Content" tab, and in that there's a checkbox for enabling Javascript. Along with that is an "Advanced" button that brings up another dialog, wherein one finds a checkbox to allow (or disallow) the raising and lowering of windows by page code.

编辑:这是一个测试页: http://gutfullofbeer.net/focus1.html ,当页面调用窗口时,你应该可以看到Firefox 引发一个窗口.focus()。您必须设置浏览器,以便在新的单独窗口而不是选项卡中打开新窗口(使用 window.open()创建),否则您可以打开时撕掉辅助页面的标签页。

edit: Here is a test page: http://gutfullofbeer.net/focus1.html and you should be able to see that Firefox will raise a window when the page calls window.focus(). You must either have the browser set up so that new windows (created with window.open()) open up in a new separate window instead of a tab, or else you can tear off the tab of the secondary page when it opens.

这篇关于window.focus(),self.focus()无法在firefox中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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