I have the following script that used to work with FF2. Now I get under FF3:

TypeError: document.getElementByID('content') is null


function Sounding(){
var yr = "08";
var myArray =  new Array();												 
	myArray[0] = new Date() ;     												 
var mes =  (myArray[0].getMonth() );	 
	if (mes.length = 2)
	mes = mes +1;					 
	mes = "0"+mes;
var day =  (myArray[0].getDate() );		
	if (day.length = 1)
	day = "0" + day;

var align= '<p align="center">';
var img = '<img src="'; 
var http = 'http://www.spc.noaa.gov/exper/soundings';
var slash = '\/';
var obs = '12_OBS/OAX.gif">';
var theString=align+img+http+slash+yr+mes+day+obs+"</p>";


The code created should look like this:

<p align="center"><img src="http://www.spc.noaa.gov/exper/soundings/08070112_OBS/OAX.gif"></p>

is displayed correctly (alert) but it ends up issuing the error message above (in red font).

Could anyone tell me what is wrong here? I can't find the problem.


the part where it reads 080701 changes daily(obvious). But if in a test no results are shown and no message is issued, the try to change 12OBS to 00OBS.

The result should be a very "weird" looking meteorological stuff.

Thanks for any help

8 Years
Discussion Span
Last Post by pakoppan

Well the error is generated when you try to get an element that doesn't exist so the simple question is, does the element with the ID "content" exist on the page before you make that call?



Thank you or your quick reply.

Now, <div id=content"></div> WAS indeed missing and I missed this probably because of the many other changes I did in that page.

Now, this is not part of the problem but it is interesting to notice that if I call the page from within Dreamweaver with file>Preview in Browser, IE7 brings the page correctly.

Using FF3, the script is not executed for some reason (it was under FF2). I get no alert message and the graph doesn't show up.

I have to load the page into the web server and then both browsers work fine.

Anyway, that was a stupid mistake of mine and thanks for placing the correct question to me in your reply. That was great.

Thank you again

Have a nice 4th of July

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.