In my getGroupPages() function below, I am updating the contents of the Nav frame with a map.html. then I run my mapTitleUpdate() function to update the title of the page that I just loaded. However, eventhough the mapTitleUpdate()call is after the top.Nav.location = line, it is updating the label of the previous page and then loads the map.html in the frame. Why?
var currentGroup = "start";
var pageNum = 1;
var maxPages = 1;
displayPage = "data/"+currentGroup+"/"+pageNum+".html";
mapPage = "data/"+currentGroup+"/map.html";
Browsers are known as "threaded interpreters". The location change is launched as a thread, and interpretation continues with the next line in the script. Since changing location is a longer process, the title change can occur before the new page has finished loading.
Two ways to fix this come to mind: 1) pass the desired title through the URL (?title=whatever) and let the new page handle it, or 2) use the onload of the window to change the title.