I am wondering how javascript functions load or run.
Take for example i have got these block of javascripts functions;
<span id=indicator></span>
function BlockOne(){
var textToWrite = document.createTextNode("I am ");
document.getElementById("indicator").appendChild(textToWrite);
}
//==========
function BlockTwo(){
var textToWrite = document.createTextNode("Going ");
document.getElementById("indicator").appendChild(textToWrite);
}
//=========
function BlockThree(){
var textToWrite = document.createTextNode("To School ");
document.getElementById("indicator").appendChild(textToWrite);
}
function RunAll(){
BlockOne();
BlockTwo();
BlockThree();
}
window.onload=RunAll();
Please which of these block of function run first or in what order are they going to run.
BlockThreewill run but none of the others()to the end of each function.window.onload=BlockOne=BlockTwo=BlockThree;<-- does not do what you think it does.window.addEventListener("load", yourFunction, false)instead ofwindow.onload = yourFunctionunless you need to support old browsers.