Results 1 to 3 of 3

Thread: messed up running order

  1. #1
    Join Date
    Aug 2004

    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;

    function getGroupPages()
    displayPage = "data/"+currentGroup+"/"+pageNum+".html";
    mapPage = "data/"+currentGroup+"/map.html";

    top.Main.location = displayPage;
    top.Nav.location = mapPage;

    }//end getGroupPages()

    function pageNumberUpdate()
    var whichPage = "<span id='pageNumber'> Page " + pageNum + " of " + maxPages + "</span>";
    parent.Top.document.getElementById('pageNumberHolder').innerHTML = whichPage;/**/
    }//end pageNumberUpdate()

    function grabPageNum(num)
    }//end grabPageNum()

    function mapTitleUpdate()
    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.

  2. #2
    Join Date
    Nov 2002
    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.

  3. #3
    Join Date
    Aug 2004
    Thanks a million! That makes sense and I think either one of those things will work for me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center