window.focus(), self.focus() 在 Firefox 中不起作用 [英] window.focus(), self.focus() not working in firefox

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

问题描述

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

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/15http://localhost/nisanth/admin/Chat/index/chatId/16

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

如果 user 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 的复选框.与 that 一起是一个高级"按钮,它会打开 另一个 对话框,其中可以找到一个复选框以允许(或禁止)通过页面代码升高和降低窗口.

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 并且您应该能够看到当页面调用 window.focus() 时 Firefox 弹出一个窗口.您必须设置浏览器,以便新窗口(使用 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天全站免登陆