messed up running order
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";
top.Main.location = displayPage;
top.Nav.location = mapPage;
var whichPage = "<span id='pageNumber'> Page " + pageNum + " of " + maxPages + "</span>";
parent.Top.document.getElementById('pageNumberHolder').innerHTML = whichPage;/**/
var groupTitle = currentGroup.substr(0,1).toUpperCase() + currentGroup.substring(1, currentGroup.length);
var mapTitleCode = '<h3 class="mapTitle">' + groupTitle + ' Pages</h3>';
parent.Nav.document.getElementById('mapTitle').innerHTML = mapTitleCode;
Last edited by killiank; 09-29-2004 at 09:07 AM.
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.
Thanks a million! That makes sense and I think either one of those things will work for me.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)