+ 3
Pls help me to solve an error
9 Answers
+ 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);
}
+ 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);
}
+ 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
+ 3
Thank u it's working
https://code.sololearn.com/WOppv9GjmF8G/?ref=app
+ 1
But I want to print success after loading
https://code.sololearn.com/WOppv9GjmF8G/?ref=app
+ 1
ok
0
posted comment on the code
0
where the windos
- 1
Try to learn debugging.....