我尝试使用生成的私人消息弹出窗口进行 Socket.IO 聊天。我在弹出窗口代码中使用 windows.opener var 来访问主页中的变量和函数。在 Firefox 和 Chrome 中,window.opener.socket.on(...) 函数从弹出窗口代码成功启动,但 IE9 不会。Node.js 服务器在后台发送和接收事件。我使用以下代码:
     //in index.php
    var socket = io.connect('http://localhost:8080');
     //other code
    $("#users .user").live('click',function(){
    //other code
    popUpWin[client_id]=window.open('private.php', client_id, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width=300,height=400,left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');         
    //other code        
    });
    //in private.php
    //other code
    window.opener.socket.emit('popup',window.opener.client_id);//This work!         
    window.opener.socket.on('private_message', function (data) {This not work, private message event is send!
        $("#private_data_recieved").append('<div><b>'+data.nick+':</b> '+parseString(data.message)+'</div>');
        playSound();                        
    }); 
        //other code