Solved

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

Posted on 2008-10-07
5
514 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
ID: 22658197
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
ID: 22658239
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
ID: 22658548
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
ID: 22684922
Solved by myself :)
0
 
LVL 42

Expert Comment

by:David S.
ID: 22685225
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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-…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

808 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