The loading sequence for the javascript in the "intro" div is currently causing a delay. The background image loads first, followed by the javascript, resulting in a slow overall load time. Is there a way to display a "loading please wait" message within the "intro" div until it fully loads? Ideally, I want the intro section to load before anything else on the page.
Here is the Javascript code:
var tl = new Array(
"=======================",
" Welcome user, ",
" ###########################################"
);
var speed = 50;
var index = 0;
text_pos = 0;
var str_length = tl[0].length;
var contents, row;
function type_text() {
contents = '';
row = Math.max(0, index - 20);
while (row < index)
contents += tl[row++] + '\r\n';
document.forms[0].elements[0].value = contents + tl[index].substring(0, text_pos) + "_";
if (text_pos++ == str_length) {
text_pos = 0;
index++;
if (index != tl.length) {
str_length = tl[index].length;
setTimeout("type_text()", 500);
}
}
else setTimeout("type_text()", speed);
}
This script types out text letter by letter in a text area within the "intro" div. However, the issue is that it only starts running after the entire page has finished loading. It waits around 15 seconds before beginning to print the text.