Hallo,
ich bin grad dabei einen Chat zu programmieren. Nur funktioniert der automatische Reload leider nicht. Kann mir da jemand weiterhelfen. Hier das Script wie es vom Browser ausgegeben wird:
Die getmassage-datei ist diese
ich bin grad dabei einen Chat zu programmieren. Nur funktioniert der automatische Reload leider nicht. Kann mir da jemand weiterhelfen. Hier das Script wie es vom Browser ausgegeben wird:
PHP-Code:
<div id="message">
<!-- <meta http-equiv="refresh" content="1">-->
<STYLE>
body,td {
font-family:verdana;
font-size:11px;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = getObjNN4(document,name);
this.style = this.obj;
}
}
function getObjNN4(obj,name)
{
var x = obj.layers;
var foundLayer;
for (var i=0;i<x.length;i++)
{
if (x[i].id == name)
foundLayer = x[i];
else if (x[i].layers.length)
var tmp = getObjNN4(x[i],name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}
//-->
</SCRIPT>
<script type="text/javascript" >
var g_remoteServer = "getmessage.php?room=flirtroom_1";
var g_intervalID;
function callServer()
{
var head = document.getElementsById('message');
var old = document.getElementById('lastLoadedCmds');
if (old) head.removeChild(old);
script = document.createElement('script');
script.src = g_remoteServer;
script.type = 'text/javascript';
script.defer = true;
script.id = 'lastLoadedCmds';
void(head.appendChild(script));
}
g_intervalID = setInterval(callServer,1000);
callServer();
</script>
<style>
.userboxx {border: solid 1px #ff0000; width:230px; height:400px; overflow:auto}
.userboxx a {text-decoration: none; font-size: 13px; font-weight: bold; font-family: verdana, sans-serife;}
.userboxx a:link {text-decoration: none; font-size: 13px; font-weight: bold; font-family: verdana, sans-serife;}
.userboxx a:visited {text-decoration: none; font-size: 13px; font-weight: bold; font-family: verdana, sans-serife;}
.userboxx a:hover {text-decoration: none; font-size: 13px; font-weight: bold; font-family: verdana, sans-serife;}
</style>
</head>
<body bgcolor="#000000">
<link rel="stylesheet" type="text/css" href="../css/stilvorlage4chat.css">
<div style="margin: 10px;">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>
<div id='msgbox' style="background-color: #ffffff; font-size: 13px; font-
family: courier new, verdana; border: solid 1px #000000; width:390px;
height:400px; overflow:auto;overflow-x:hidden;">
<span style=color:#><span style=color:#77aba4>u betritt den
Raum</span></span><br></div></td><td>
<div id='userbox' class="userboxx"
style="background-color: #ffffff; font-size: 13px;
font-family: courier new, verdana; border: solid 1px #000000;">
<table border='0' cellpadding='0' cellspacing='0'><tr><td><span
style="color:#77aba4;
font-weight: bold; font-size: 14px;">u</span>
</td><td width='40' align="right">
<img src='../images/4.gif' border='0' alt='weiblich - gay'>
</td></tr></table></div></td><td>
<div style="background-color: #ffffff; border: solid 1px #000000; width:120;height: 400px; overflow:auto">
Werbung
</div></td>
</tr>
</table></div>
<div style="margin: 13px;">
<form name='form1' method='Post' action='chatraeume.php?PHPSESSID=3cb7833a90af15b001bb5b3737101f44'>
<INPUT TYPE="hidden" name='room' value="flirtroom_1">
<input type="text" name="msg" style="width: 345px;">
<input type="Submit" value="Send">
<br>
<span style='font-family:verdana;font-size:10px;color:#ff0000'><br>
* Um Dich abzumelden, schließe
einfach diese kleine umrandete Fenster</span>
</form>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.form1.msg.focus();
//-->
</SCRIPT>
</div> </td>
</tr>
</table>
</div></td>
</table>
PHP-Code:
<?php
@session_start();
include_once("chat.inc.php");
$mychat=new Chat($_REQUEST['room']);
$message=$mychat->getMessageForUser($_SESSION['SES_USER_NAME']);
$message=$mychat->getMessage();
$users=$mychat->getUsers();
if(!empty($message))
{
?>
var mydiv=new getObj('msgbox');
mydiv.obj.innerHTML="<?=$message?>";
var userbox=new getObj('userbox');
userbox.obj.innerHTML="<?=$users?>";
mydiv.obj.scrollTop=10000;
mydiv.obj.scrollTop=10000;
<?php }?>
Kommentar