Solved

'null' is null or not an object error on javascript

Posted on 2008-10-07
5
510 Views
Last Modified: 2012-08-13
I've successfully set up Chat (http://www.ebrueggeman.com/phpsimplechat/index.php)
On Firefox and Google Chrome it works fine without errors, but with MSIE6,7 it complains:
'null' is null or not an object error on javascript , about this function

function user_active_ajax(myvar) {
      var chatusers = document.getElementById('div_chat_users');
      var currentuser = document.getElementById('div_current_user');
      //JS Logic
      var messageArray = myvar.split(',');
      var resultHTML='';

      for (var i=0; i < messageArray.length; i++) {
            resultHTML = resultHTML      + (messageArray[i]+'<br/>')
      }
      chatusers.innerHTML = resultHTML; <------------------------------------ error line
}

from ajax/functions.js

Ideas?
0
Comment
Question by:tomzu
5 Comments
 
LVL 5

Accepted Solution

by:
mverschoof earned 75 total points
Comment Utility
is the script loaded before the div (div_chat_users)? If so, it doesn't know where to place the innerHTML code

Hope this helps
0
 
LVL 2

Assisted Solution

by:priya_patil
priya_patil earned 50 total points
Comment Utility
if the error line is thid than this means that
var chatusers = document.getElementById('div_chat_users'); returns null
IE7 is not able to find any div with id "div_chat_users"
0
 

Author Comment

by:tomzu
Comment Utility
That partly solved my problem. Is anyone willing to help more?

This is example page of chat script http://www.ebrueggeman.com/phpsimplechat/examples.php

If I use MSIE, after I post a message, all messages dissapear. When you post again, they show up for some time (~2sec) then dissapear again.
0
 

Author Comment

by:tomzu
Comment Utility
Solved by myself :)
0
 
LVL 42

Expert Comment

by:David S.
Comment Utility
For anyone who finds this later, would you please tell us what the problem turned out to be and what your solution was?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now