0
External javascript
Hi guys when tried putting test.js at the last line of the body, the alert box was shown first instead of the page. Can someone help me with this issue? Much thanks
7 Réponses
+ 5
//As Gordon said use setTimeout(), it makes alert box pop after 3000 ms(3s)
setTimeout(function() {
alert("hello test")
}, 3000 )
+ 4
setTimeout()
+ 2
//Maneren actually page will not be visible on foreground, we only see alert box, but page actually runs in background, it's not a problem simply is a window loading. You can do like this to make alert box load when page is fully loaded
window.onload = function(){
alert('Hello world ');
}
0
Gordon Shudarshan Rai 👑 thanks
0
Gordon Shudarshan Rai 👑
Just, can you tell my why this happens? Is it because of asynchronous execution of code or why?
0
Shudarshan Rai 👑 But i still see alert box and then page. What if i want to make alert box pop up after page shows (without setTimeout for better precision).
0
Also when i do
changeHTML(); //like edit text or something
alert("alert");
alert is shown before HTML.