I'm calling a function load() on body's onload event. Sometimes this function work and sometime it doesn't. As per my understanding, until the body is completely loaded, this function will not get called. Is there any way I can call this function before the page get loaded ?
Here is home.html:
<script src="js/custom.js"></script>
<script src="js/props.json"></script>
<body onload="load()">
<a id="beginner">Beginner Level</a>
<div id="beginner-sub" class="well">
<!-- append content here -->
</div>
</body>
custom.js load function:
function load() {
var mydata = JSON.parse(beginner);
var rows = "";
for(var x=0; x < mydata.length; x++)
{
rows += '<a href="'+mydata[x].url+'">'+mydata[x].title+'<i class="fa fa-hand-o-right pull-left" aria-hidden="true"></i></a><hr>';
}
$("#beginner-sub").append(rows);
$("#beginner-sub hr:last-child").remove()
}
And this is my props.js
beginner = '[{"title" : "Simple Program", "url" : "simple.html"}, {"title" : "Check Palindrome", "url" : "palindrome.html"}]';