Hey Why Does my javascript Always return the Uncaught type error when everything is fine | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Hey Why Does my javascript Always return the Uncaught type error when everything is fine

https://code.sololearn.com/WbPgEIorhzRk/?ref=app

10th Nov 2017, 12:47 PM
MohanPierce
MohanPierce - avatar
4 Answers
+ 4
You have to use window.onload before your "main" js code. window.onload = function() { //code }
10th Nov 2017, 1:25 PM
Cool Codin
Cool Codin - avatar
+ 2
Well Maybe In desktop I could add defer In my tag how can i stop this in This app
10th Nov 2017, 1:06 PM
MohanPierce
MohanPierce - avatar
0
Because your JS code is running before the HTML body has loaded.
10th Nov 2017, 1:05 PM
John Wells
John Wells - avatar
0
use onload attribute to body and function around code. <body onload="init();"> function init() { // js code }
10th Nov 2017, 1:07 PM
John Wells
John Wells - avatar