23rd Dec 2018, 6:20 AM
sid
sid - avatar
9 Respostas
+ 8
Your check if the value reached 100 is in the wrong place It is excuted only once, and goes to the else condition. From there the only function which is called is the "loading" one as part of the interval Just place your checks in there window.onload=function(){ var arr,a,inter; arr=document.getElementsByTagName("progress"); var a=arr[0]; function loading(){ if(a.value >= 100){ document.write("success"); clearInterval(inter); } a.value+=5; } inter=setInterval(loading,100); }
24th Dec 2018, 6:44 AM
Burey
Burey - avatar
+ 10
Wrap it all with window.onload function + replaced the while loop (you were creating many intervals which caused the SL app to crash due to too many calls) window.onload = function(){ var arr,a, interval; arr=document.getElementsByTagName("progress"); var a=arr[0]; function loading(){ if(a.value >= 100){ clearInterval(interval); } a.value+=5; } interval = setInterval(loading,100); }
23rd Dec 2018, 5:45 PM
Burey
Burey - avatar
+ 8
Script loaded before DOM. Place your JS code which calls the html object within a window.onload function. window.onload = function() { // Your JS code here } Please check this post by Burey: https://www.sololearn.com/post/7444/?ref=app
23rd Dec 2018, 7:37 AM
Hatsy Rei
Hatsy Rei - avatar
24th Dec 2018, 4:10 PM
sid
sid - avatar
+ 1
But I want to print success after loading https://code.sololearn.com/WOppv9GjmF8G/?ref=app
24th Dec 2018, 1:05 AM
sid
sid - avatar
+ 1
ok
27th Dec 2018, 5:05 AM
Mwesigwa Jovan Jonathans
Mwesigwa Jovan Jonathans - avatar
0
posted comment on the code
24th Dec 2018, 9:46 AM
Ḿổḩảḿḿẻď Ấḿiň
Ḿổḩảḿḿẻď Ấḿiň - avatar
0
where the windos
24th Dec 2018, 9:47 AM
Ḿổḩảḿḿẻď Ấḿiň
Ḿổḩảḿḿẻď Ấḿiň - avatar
- 1
Try to learn debugging.....
24th Dec 2018, 2:55 AM
Jatin
Jatin - avatar