检测窗口是否打开jQuery PHP

Say I have a menu with the following

<a href="/chat.php" class="newwindow">Chat</a>

$(".newwindow a").click(function(e){
    e.preventDefault()
    window.open($(this).attr('href'),'Chat', 'width=500, height=576');
        return false;
});

So this jQuery along with HTML opens up a window for chat.php

Is there a way to detect across the rest of my website if this chat.php window is currently open and when it has closed too?

Reason being the chat is on every page of the website and when the use opens into a new window I would like to remove the chat from the active webpages

doulan9188
doulan9188 是不可用的onload/onunload事件?
大约 7 年之前 回复

1个回答

this is how i check if the window was opened/blocked

var url = $(this).val();
var win  = window.open(url);
/* Detectar posible bloqueo de popups */
if (win == null || typeof(win) == "undefined" || (win == null && win.outerWidth == 0) || (win != null && win.outerHeight == 0) || win.test == "undefined"){
                    window.location.href = url;
}else if (win){
    win.onload = function(){
    if (win.screenX === 0) {
            win.close();
    }
   };
}
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐