問題描述
大家好,我正在開發(fā)一個聊天應(yīng)用程序...我有多個聊天窗口...我想知道哪個窗口包含新消息...我有以下代碼..
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....
例如,網(wǎng)址就像http://localhost/nisanth/admin/Chat/index/chatId/15http://localhost/nisanth/admin/Chat/index/chatId/16
http://localhost/nisanth/user/Chat/index/chatId/15一>http://localhost/nisanth/user/Chat/index/chatId/16
如果 user 16
輸入我需要關(guān)注的消息
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
推薦答案
如果設(shè)置了安全選項,F(xiàn)irefox 只會服從引發(fā)窗口的請求,并且默認(rèn)情況下未設(shè)置.據(jù)我所知,Chrome 根本不會關(guān)注 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 設(shè)置在工具"->選項"(Linux 上的編輯->首選項",可能是 MacOS)對話框中.有一個內(nèi)容"選項卡,其中有一個用于啟用 Javascript 的復(fù)選框.與 that 一起是一個高級"按鈕,它會打開 另一個 對話框,其中可以找到一個復(fù)選框以允許(或禁止)通過頁面代碼升高和降低窗口.
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 并且您應(yīng)該能夠看到當(dāng)頁面調(diào)用 window.focus()
時 Firefox 將 彈出一個窗口.您必須設(shè)置瀏覽器,以便新窗口(使用 window.open()
創(chuàng)建)在新的單獨窗口而不是選項卡中打開,或者您可以撕下打開時的第二頁.
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.
這篇關(guān)于window.focus(), self.focus() 在 Firefox 中不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!