My Opera is closing 3rd of March

Hoang Ha's Blog

Hoang Ha lives in HCMC, Viet Nam

document[...] is null or not an object - javascript

Hello:

I am getting the following intermittent error when i try to access my application.

A runtime error has occurred,
Do you wish to debug?

Line: 31
document...tElementById(...) is null or not an object

If we debug the error, the problem is in the next code line at the footer.xsl file:

document...tElementById( "controlButtons" ).innerHTML = strRightHTML;

Do you know if this error is common and what could be the cause of this?

We cannot reproduce this error at will. Sometimes the error appears but not always. Sometimes the error appears in other lines at runtime (like 51). So its really hard to pinpoint exactlt what the problem is.

answer:
This error happen when getElementById() method of document object no find out a Id of element.
Look at the following below example:
    function movepic(img_name,img_src) {
		
            	document[img_name].src=img_src;
        }
  using by
     [html:a href="Product/Default.aspx?name=Access Floor" onmouseover="movepic('img1','images/1a.png')" 
                                    onmouseout="movepic('img1','images/1.jpg')"]
           <img id="img1" style="border:0px" src="images/1.jpg" alt="Access Floor" />
     </a>


a error brought out: document[...] is null or not an object.

I find a solution to fix this error by using getElementById() method:

   function movepic(img_name,img_src) {
		document.getElementById(img_name).src=img_src;
        }


my program good run.

Hope this helps.

Microsoft Ra Mắt Phiên Bản ASP.NET 3.5 Extensions CTP Preview Lỗi khi upload website lên host

Write a comment

New comments have been disabled for this post.

February 2014
M T W T F S S
January 2014March 2014
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28