View Full Version : Done with error on the page

10-14-2003, 10:53 AM
i get this error, 'Done with error on the page'

line: 36
char: 1
Error: 'document.getElementById(...)' is null or not an object
Code: 0
URL: http://se5:8080/home/squiremech/project/education.jsp

when i open up my file in the browser..

i am using javascript as my side nav pop up menu with the newly added javascript i found online,
the new javascript(which show scrolling images ) is working, but the old nav pop up menu dont seem to be working.:(

here are the codes:

<script type="text/javascript"><!--

//thumbnail script
thumb=new Image(); //line 36
thumb2=new Image();
thumb3=new Image();
thumb4=new Image();
//thumb5=new Image();
//thumb6=new Image();


function thumbtobig(thumbs){
if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="ITE Balestier Modern college development with laboratories, classroom, workshops, library etc for technical education.";}

else if(thumbs==2){document.getElementById("large").src=thumb2.src;ins_text="Singapore Chinese Girl's School One of the modern development with 62 classrooms, multi-purpose hall, gymnasium, dance studio and a 600-seats theatre for a prestige secondary and primary schools.";}

else if(thumbs==3){document.getElementById("large").src=thumb3.src;ins_text="University Cultural Centre A center consists of a 1800-seats auditorium, a 450-seats theatre, and a museum annexe for the National University of Singapore.";}

else if(thumbs==4){document.getElementById("large").src=thumb4.src;ins_text="United World College of South East Asia A college for peoples from various countries resides in Singapore.";}

document.getElementById("caption").replaceChild(document.createTextNode(ins_text), document.getElementById("caption").firstChild);

return false;}


<SCRIPT LANGUAGE="JavaScript1.2" SRC="../include/dynlayer.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac));

function popUp(){return};
function popDown(){return};

if (!ver4) event = null;

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
function init() {


if (isMenu) {
document.write("<SC"+"RIPT LANGUAGE='JavaScript1.2' SRC='../include/hierArrays_main.js'><\/SCRIPT>");


function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

<BODY LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" BGCOLOR="#CCE0D6" ONLOAD="init();MM_preloadImages('../media/nav_kms2_on.gif');thumbtobig(thumbs)">
<!---- Here Start the header ---->

<TD VALIGN=middle ALIGN=left><A HREF="../default.html"><IMG SRC="media/img_logo.gif" WIDTH=79 HEIGHT=46 HSPACE=8 BORDER=0 ALT="Squire Mech Logo"></A></TD>
<TD VALIGN=top ALIGN=right><IMG SRC="media/img_top.jpg" WIDTH=654 HEIGHT=57 BORDER=0></TD>

pls enlighten me... thanks in advance!;)

10-14-2003, 11:39 AM
I can not see that URL, That page can not be displayed.

Willy Duitt
10-14-2003, 11:52 AM
It seems he has his http server offline.

Taking your posted code, Line 36 appears
to be within your external javascript source file.

<SCRIPT LANGUAGE="JavaScript1.2" SRC="../include/dynlayer.js"></SCRIPT>

Other than that, the only other issue I see is your thumbs start
at 1, whereas you should be counting from 0. This would cause
your script to fail.

thumb=new Image(); //line 36
thumb2=new Image();
thumb3=new Image();
thumb4=new Image();
//thumb5=new Image();
//thumb6=new Image();

10-14-2003, 12:23 PM
The problem could be you access the element (via document.getElementById) before it has been loaded in the page.

If this line:


is the first document.getElementById call in your page, this is the source of the problem.

10-15-2003, 04:14 AM
hmm... :confused:

As i dun have much knowledge on javascript, is there by any chance tat i can have the solutions to these prob?

Willy Duitt
10-15-2003, 04:26 AM
What happened to your linked page?

Are you a student and is this an assignment?

You say, "javascript i found online" but, where's the credits?

pls enlighten me... thanks in advance! :)


10-15-2003, 05:01 AM
my attachment company allows me to outsource javascripts online...

i juz have to improve the interface of their website tats all...
but i'm struck...

10-16-2003, 06:35 AM
Have you pinpointed the source of the problem? You can't solve the problem if you don't know its source. I already told you the possible cause...You didn't confirm if I was correct or not in my observation.