Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  173] [ 5]  / answers: 1 / hits: 29465  / 13 Years ago, wed, may 11, 2011, 12:00:00

Can anyone explain what is theses errors?




Uncaught TypeError: Cannot set
property 'innerHTML' of null



Uncaught TypeError: Cannot read
property 'style' of null



Uncaught SyntaxError: Unexpected token
ILLEGAL



Uncaught TypeError: Object #
has no method 'dispatchEvent'




This is my test Website


More From » jquery

 Answers
19

At some point in the page you have:



function display_price(price, oid)
{
...

element = document.getElementById(oid);
if (valor != 'NaN' && valor != null && valor != '')
{
element.innerHTML = valor + money_simbol;


The last line is causing the error because element is null. You should add a condition to the if(): that is, change this line:



if (valor != 'NaN' && valor != null && valor != '')


to this:



if (element && valor != 'NaN' && valor != null && valor != '')


In other words, it's a good practice to always check the return value of a function before accessing its properties.


[#92290] Tuesday, May 10, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jack

Total Points: 557
Total Questions: 96
Total Answers: 80

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;