By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

Error - working in IE and MOzilla but giving error null or not a object

P: 23
Error - working in IE and MOzilla but giving error null or not a object:
Guys i am giving you snippet of code , where it is javascript digital clock , It is showing time and working properly but it is giving error in log

Expand|Select|Wrap|Line Numbers
  1. function adidas(){ 
  2.     theTime=setTimeout('dotime();',1000);
  3.     ser_sc = ser_sc+1;
  4.     var hr= ser_hr+100 ;
  5.     var mn= ser_mn+100 ;
  6.     var se= ser_sc+100 ; 
  8.     if(hr==100){
  9.         hr=112;am_pm='am';
  10.     }
  11.     else if(hr<112){
  12.         am_pm='am';
  13.     }
  14.     else if(hr==112){
  15.         am_pm='pm';
  16.     }
  17.     else if(hr>112){
  18.         am_pm='pm';hr=(hr-12);
  19.     }
  20.     tot=''+hr+mn+se;
  21.     document.hr1.src = '/flash_files/digits/dg'+tot.substring(1,2)+'.gif';// HERE IT IS GIVING ERROR
  22.     document.hr2.src = '/digits/dg'+tot.substring(2,3)+'.gif';
  23.     document.mn1.src = '/digits/dg'+tot.substring(4,5)+'.gif';
  24.     document.mn2.src = '/digits/dg'+tot.substring(5,6)+'.gif';
  25.     document.se1.src = '/digits/dg'+tot.substring(7,8)+'.gif';
  26.     document.se2.src = '/digits/dg'+tot.substring(8,9)+'.gif';
  27.     document.ampm.src= '/digits/dg'+am_pm+'.gif';
  28. }
  29. adidas();
Help me out guys ....

Thanks in advance.
Jul 14 '10 #1
Share this Question
Share on Google+
7 Replies

Expert Mod 5K+
P: 5,320
what does the dotime()-method do? ... when do you start the script ... from the onload or directly when the page is read by the browser?
Jul 14 '10 #2

P: 23
Sorry , dotime() is adidas();
Jul 14 '10 #3

Expert Mod 5K+
P: 5,320
??? so that was the error? ... otherwise you should tell when the function is executed first. when it isn't first fired from the page's onload event then the DOM isn't reliably ready to be used and thus a node reference could fail with the error that you encounter.
Jul 15 '10 #4

P: 23
ya the function is called on onLoad ,
And might be this is the reason behind that , so any solution.
Jul 15 '10 #5

Expert Mod 5K+
P: 5,320
besides of the diff in the path i cannot see ond/or say anything without having a look at the surrounding code or better a testpage ...
Jul 16 '10 #6

P: 23
I am sorry but not getting you ... Can you please elaborate it again ...
Jul 17 '10 #7

Expert Mod 5K+
P: 5,320
in line 21 of the above posted code the path differs from the other img-paths - in case the path is correct then it would be relevant to see the rest of the code or better having a testpage. or install the firebug extension in firefox and tell what javascript error occurs ...

you might even check what the


nodes are during the execution ... just place an alert or log in the code. i suppose that those nodes are image-nodes? how does they look like in the code? probably it would be better to give them ids and retrieve them with the document.getElementById() method ...
Jul 18 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.