To be more specific let me tell you that its a strange problem. the script error doesnt comes in my window but it is coming in other internet explorers.
I have made the same changes which you have told me. I am creating a chat application and the window in which i have put this code appears when i click any user in another window.
The concept is like this. A main window is having all the users who are online. Whenever i click the users who are online in that window a new window appears. And if a sender sends a message in that window another window appears at the receiver end at that time this null error comes. i have now coded it like this.
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Regalmail-Beta Chat</title>
<style type="text/css">
#chatContents{height:300px; width:510px;}
</style>
<script type="text/javascript">
function resetForm()
{
document.getElementById("message").value = "";
document.getElementById("message").focus();
}
function focusForm()
{
document.getElementById("message").focus();
}
function focustext()
{
var name=window.name;
<?
$sql2 = "SELECT chat_tmp_usr_id1 FROM chat_temp_table";
$res2 = mysql_query($sql2);
if(mysql_num_rows($res2))
{
while($row2 = mysql_fetch_array($res2))
{?>
var id25='<?echo "".$row2['chat_tmp_usr_id1']?>';
if(name==id25)
{
document.getElementById("message1").value=name;
}
<?}}?>
document.getElementById("statusmessage").style.display="inline";
}
function losttext()
{
document.getElementById("statusmessage").style.display="none";
}
var cWindow;
var cDocument;
var id11;
window.onload=function()
{
var chatContents = document.getElementById("chatContents");
if(chatContents.contentWindow)
{
cWindow = chatContents.contentWindow;
cDocument=cWindow.document;
}
}
function insertMessages(content)
{
//place the new messages in a div
var newDiv = cDocument.createElement("DIV");
newDiv.innerHTML = content;
//append the messages to the contents
cDocument.getElementById("contents").appendChild(newDiv);
//scroll the chatContents area to the bottom
cWindow.scrollTo(0,cDocument.getElementById("contents").offsetHeight);
}
if(parent.insertMessages && document.getElementById("contents"))
parent.insertMessages(document.getElementById("contents").innerHTML);
</script>
<style>
body
{
background-color: #EBF3FB;
color: #000000;
}
</style>
<?
$sql1 = "SELECT chat_user_id,chat_user_id1,chat_user_name,Message FROM chat_table WHERE chat_user_id=".$SESSION['Chat3_UserID']." and chat_flag='".$flag10."'";
$res1 = mysql_query($sql1);
if(mysql_num_rows($res1))
{
echo '<div id="contents">';
while($row1 = mysql_fetch_array($res1))
{
if($row1['chat_user_id']==$SESSION['Chat3_UserID'])
echo '<div class="ylayout-active-content" style="font-size:14px;font-face:arial;"><strong>'.htmlspecialchars($row1['chat_user_name']).':</strong>'.htmlspecialchars($row1['Message']).'</div>';
}
echo '</div>';
}
?>
</head>
<body>
<iframe id="chatContents" name="chatContents" src="contents.html"></iframe><br>
<div style="display:none;color:red;height:1px;" id="statusmessage"><?echo "".$_SESSION['Chat1_UserName']?> is typing</div><br><br>
<form target="post" method="post" action="post.php">
<input type="text" onkeydown="javascript:focustext();" onkeyup="javascript:losttext();" name="message" id="message" style="width: 460px;height: 40px;" />
<input type=hidden name="message1" id="message1" value="" />
<input type="submit" value="Send" class="submit" style="width: 55px;height: 47px;" />
</form>
<iframe id="post" name="post" src="post.php" style="width: 0px; height: 0px; border: 0px;"></iframe>
<iframe id="thread" name="thread" src="thread.php" style="width: 0px; height: 0px; border: 0px;"></iframe>
</body>
</html>
Mandar π