document[...] is null or not an object - javascript
Tuesday, December 18, 2007 8:41:42 AM
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.
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.






