Вот весь код:
Родитель:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="/images/faviconnew.ico" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>OnlineConsultant</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="http://test.ru/css/chat.css" />
<script type="text/javascript">
var OnlineConsultantWindow = null;
var checkWindowOpenInterval = false;
function reloadCheckOpenWindow(target){
alert("Прием")
OnlineConsultantWindow = target;
if(checkWindowOpenInterval == false){
checkOpenWindow()
}
}
function windowReady(myWindow){
OnlineConsultantWindow.myWindow(OnlineConsultantWindow)
}
function exitChatWindow(){
OnlineConsultantWindow = null;
clearInterval(checkWindowOpenInterval);
alert("Окно закрыто!");
}
function checkOpenWindow(){
checkWindowOpenInterval = setInterval(function(){
if (OnlineConsultantWindow.closed) {
clearInterval(checkWindowOpenInterval);
checkWindowOpenInterval = false
exitChatWindow()
}
}, 200)
}
$(document).ready(function () {
$(".OnlineConsultantMax .hide").click(function () {
OCShow();
var n = OnlineConsultantWindow.document.getElementById('OnlineConsultantWindow');
$(n).html("jhgf")
})
$(".OnlineConsultantMin").click(function () {
OCShow();
})
$(".OnlineConsultantMax .expand").click(function () {
if(OnlineConsultantWindow != null){
OnlineConsultantWindow.focus();
}else{
var resizable = "resizable=1"
if($.browser.msie)
{
var resizable = "resizable=0"
}
var params = 'directories=0, menubar=0, toolbar=0, location=0, width=520,height=420,toolbar=1,scrollbars=1,'+resizable;
OnlineConsultantWindow = window.open("http://testtools.ru/tested/test396/chat.php", "ChatWindow", params)
if(OnlineConsultantWindow == null){
alert("Ошибка")
}
OnlineConsultantWindow.focus()
}
})
$(".OnlineConsultantMax .inputInChat").click(function (e) {
e.preventDefault();
inputInChat();
});
$('.OnlineConsultantMax .toName').keypress(function (e) {
if (e.which == 13)
inputInChat();
});
$(".OnlineConsultantMax .send").click(function (e) {
e.preventDefault();
submitMessage();
});
$('.OnlineConsultantMax #message').keypress(function (e) {
if (e.which == 13) {
e.preventDefault()
submitMessage();
}
});
var printOnlineConsultantValue = 0;
$(".OnlineConsultantMax textarea").keypress(function () {
if (printOnlineConsultantValue == 0) {
printOnlineConsultant()
printOnlineConsultantValue = 1;
setTimeout(function () {
printOnlineConsultantValue = 0;
}, 3000)
} else {
return 0;
}
})
$(".managersShow").click(function () {
showManagers();
})
})
function strip(text) {
return text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function printOnlineConsultant() {
socket.emit('prints', { toManager: OCThisManager });
}
function showManagers() {
if ($(".OnlineConsultantMax .managersList").css("display") == "none") {
$(".OnlineConsultantMax .managersList").fadeIn(50);
$(".OnlineConsultantMax .managersShow").html("Скрыть");
} else {
$(".OnlineConsultantMax .managersList").fadeOut(50);
$(".OnlineConsultantMax .managersShow").html("Консультанты");
}
}
function getrandom() {
var min_random = 0;
var max_random = 99999999;
max_random++;
var range = max_random - min_random;
var n = Math.floor(Math.random() * range) + min_random;
return n;
}
var id = getrandom();
function submitMessage() {
var msg = strip($(".OnlineConsultantMax #message").val());
if (!msg.replace(/\s+/g, '').length) {
alert("Пустое сообщение не может быть отправлено")
return 0;
}
if (OCThisManager != null) {
var info = { toManager: OCThisManager, msg: $(".OnlineConsultantMax #message").val() }
socket.emit('pMessage', info);
setTimeout(function () {
$(".messeges").scrollTop(9999);
}, 100);
$('.OnlineConsultantMax #message').val('');
} else {
alert("Выберите менеджера")
}
}
function OCShow() {
if ($(".OnlineConsultantMax").css("display") == "none") {
$(".OnlineConsultantMax").css("display", "block");
$(".OnlineConsultantMin").css("display", "none");
$(".OnlineConsultantMin .newMessages").html("");
} else {
$(".OnlineConsultantMax").css("display", "none");
$(".OnlineConsultantMin").css("display", "block");
}
}
</script>
<style type="text/css">
*{margin: 0; padding: 0;}
body {
text-align: center;
background: #fff;
}
.content {
width: 800px;
height: 100%;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="content">
<div id="users">
Список законекченных
</div>
<div class="OnlineConsultantMax" style="display: none;">
<div class="managersList" style="display: block;">
</div>
<div class="chat">
<div class="identifier"><div class="name"></div><div><div class="hide">_</div><div class="expand">*</div></div></div>
<div class="personalMessages">
<div class="messeges" id="messeges_null">
<div class="input">
<p>Введите желаемое имя</p>
<input type="text" class="toName"/><br /><button class="inputInChat">Войти</button>
</div>
</div>
</div>
<div class="printMe"></div>
<div class="control">
<textarea placeholder=" Сообщение..." id="message" disabled="disabled"></textarea>
<span class="managersShow">Скрыть</span>
<input type="button" value="Отправить" id="id" class="send" disabled="disabled"/>
<div style="width: 100%; clear: both;"></div>
</div>
</div>
</div>
<div class="OnlineConsultantMin">
<span class="name">On-line Консультант</span><span class="newMessages"></span>
</div>
</div>
</body>
</html>
открывшийся через windows.open:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" «www.w3.org/TR/html4/strict.dtd»>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="http://test.ru/css/chatWindow.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="http://test.ru/css/chatWindowIE.css" />
<![endif]-->
<script>
var myWindowTarget
function myWindow(target){
myWindowTarget = target
}
setInterval(function(){
alert("Проверка")
if(typeof window.opener.reloadCheckOpenWindow == 'function') {
alert("отправка")
window.opener.reloadCheckOpenWindow(myWindowTarget)
}
}, 200)
</script>
</head>
<body>
<div id="OnlineConsultantWindow" class="OnlineConsultantWindow">
<div class="managersList">
</div>
<div class="chat">
<table border=0 width=100% height=100%>
<tr>
<td class="identifier">
<div class="name"></div>
</td>
</tr>
<tr>
<td class="personalMessages">
<div class="messeges" id="messeges_null">
</div>
<div class="printMe"></div>
</td>
</tr>
<tr>
<td class="control">
<textarea placeholder=" Сообщение..." id="message" disabled="disabled"></textarea>
<input type="button" value="Отправить" id="id" class="send" disabled="disabled"/>
</td>
</tr>
</table>
</div>
</div>
<script>
opener.windowReady(true)
</script>
</body>
</html>