0

WEB: Please help me finalize this code (Uncaught Type Error)

I'm finalizing my image editor Code. It says "Uncought TypeError: Cannot read.....line 446. I tried everything I could, _ no good result. Can u help me fix this problem, @ line 446, : It's supposed to make the help button's content display. ---- Also, The Hardware (CSS: line 55 ) On my phone the margin fits perfectly under the Image. But on other Devices, It Is further down away from the Image. I need help with that too, but I want to focus on the JS first. https://code.sololearn.com/Wep8Iw2ZgCiF/?ref=app

10th Jul 2019, 9:18 PM
Ginfio
Ginfio - avatar
6 ответов
+ 1
Ginfio Uncaught TypeError: Cannot read property 'addEventListener' of null Line: 446. The cause of this error is due to line 445 trying to access the document before the document is loaded. The simple fix is to move the closing bracket of the anonymous function(window.onload) to encompass the other lines of code that need to access the Document. https://code.sololearn.com/WF5IHh54qEQS/#js btw- If you don't mind asking, what device were you using when you saw the error message?
10th Jul 2019, 10:35 PM
ODLNT
ODLNT - avatar
+ 3
Shadow , ODLNT JS. Fixed Thanks!✔️
11th Jul 2019, 1:45 AM
Ginfio
Ginfio - avatar
+ 2
Shadow Can u please check it now, and see if that error is still there? Thanks
10th Jul 2019, 11:58 PM
Ginfio
Ginfio - avatar
+ 1
I can only help you with the JS, but luckily, that is rather simple. You ended your onload() function on line 443, so the variables that come afterwards that retrieve elements from the document are null since the page hasn't finished loading at initialization time. You should include everything except the very first and very last function in the onload() function, that will make it work.
10th Jul 2019, 10:34 PM
Shadow
Shadow - avatar
+ 1
ODLNT , i looked at it on DELL desktop. i made the code on my phone, so i didnt get any errors, but on the desktop i did.
10th Jul 2019, 11:53 PM
Ginfio
Ginfio - avatar
+ 1
Almost done, Ginfio, only 'cls' is currently still null. The closing brace should move to line 493 so that the last variable is covered as well, then everything will be alright. You can refer you the corrected version ODLNT linked in his answer.
11th Jul 2019, 12:07 AM
Shadow
Shadow - avatar