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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gskoli
    New Member
    • May 2010
    • 23

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

    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

    Code:
    function adidas(){ 
    	theTime=setTimeout('dotime();',1000);
    	ser_sc = ser_sc+1;
    	var hr= ser_hr+100 ;
    	var mn= ser_mn+100 ;
    	var se= ser_sc+100 ; 
    	
    	if(hr==100){
    		hr=112;am_pm='am';
    	}
    	else if(hr<112){
    		am_pm='am';
    	}
    	else if(hr==112){
    		am_pm='pm';
    	}
    	else if(hr>112){
    		am_pm='pm';hr=(hr-12);
    	}
    	tot=''+hr+mn+se;
    	document.hr1.src = '/flash_files/digits/dg'+tot.substring(1,2)+'.gif';// HERE IT IS GIVING ERROR
    	document.hr2.src = '/digits/dg'+tot.substring(2,3)+'.gif';
    	document.mn1.src = '/digits/dg'+tot.substring(4,5)+'.gif';
    	document.mn2.src = '/digits/dg'+tot.substring(5,6)+'.gif';
    	document.se1.src = '/digits/dg'+tot.substring(7,8)+'.gif';
    	document.se2.src = '/digits/dg'+tot.substring(8,9)+'.gif';
    	document.ampm.src= '/digits/dg'+am_pm+'.gif';
    }
    adidas();
    Help me out guys ....

    Thanks in advance.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    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?

    Comment

    • gskoli
      New Member
      • May 2010
      • 23

      #3
      Sorry , dotime() is adidas();

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        ??? 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.

        Comment

        • gskoli
          New Member
          • May 2010
          • 23

          #5
          ya the function is called on onLoad ,
          And might be this is the reason behind that , so any solution.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            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 ...

            Comment

            • gskoli
              New Member
              • May 2010
              • 23

              #7
              I am sorry but not getting you ... Can you please elaborate it again ...

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                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

                document.hrX

                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.getEle mentById() method ...
                Last edited by gits; Jul 18 '10, 10:40 AM.

                Comment

                Working...