window.focus(),self.focus()不工作在Firefox

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

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(); } } }); } 

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

例如url就像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

如果user 16input我需要关注的消息

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

此代码是工作正常的IE浏览器,但不是在Firefox中…请给我一个解决scheme…上述代码是在相同的HTML

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

具体的Firefox设置是在“工具” – >“选项”(在Linux上编辑 – >首选项,也许是MacOS)对话框。 有一个“内容”选项卡,在那里有一个checkbox来启用Javascript。 除此之外还有一个“高级”button,可以打开另一个对话框,其中一个checkbox允许(或不允许)通过页面代码升起和降下窗口。

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