SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Endless loop problem with onLoad

    Hi there,

    I have a function which I would like to be called by the onLoad handler. The function includes a window.open() which causes the site to refresh (and resets the status of a tree menu).

    I would need to make sure that this function only runs once every time the page is called through a link, cause otherwise I run into an endless loop.

    I also tried onClick on the page that holds the link, but it seems that the function is then executed on this page. I have different tree menus on various sites so the function needs to be executed on the target page once.

    Amy ideas how I could do this? Maybe I am thinking too complicated and there is also a way to call the function by the onClick event.

    Thanks for any help,

    regards ASchweti

  2. #2
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could You Post The Code In Question?

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, I believe these are the functions involved. If you just use one tree menu, the function is called by onclick. It changes the menu and then loads the new page. In my case it would need to change the menu on the page I am going to which is why I tried to use onLoad.

    This is how you call the function:
    Code:
    javascript:expandMenu(3)
    Here is the code:
    Code:
    // Load a page as if a node on the tree was clicked (synchronize frames)
    // (Highlights selection if highlight is available. 0 to remove highlighting.)
    function expandMenu(linkID) 
    {
    	var folderObj;
    	docObj = findObj(linkID);
    	docObj.forceOpeningOfAncestorFolders();
    	clickOnLink(linkID,docObj.link,'_top');
    }
    Code:
    function clickOnLink(clickedId, target, windowName) {
        highlightObjLink(findObj(clickedId));
        if (isLinked(target)) {
            window.open(target,windowName);
        }
    }
    Thanks, ASchweti

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if I follow well enough... but perhaps this is an idea:

    Pass an argument on the url tail to the target page. That arg can be a flag that indicates to reload or not reload, etc.

    Or use cookies instead of passing the flag in the url - but I don't think I like this idea too much.


  5. #5
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi MikeFoster,

    yes, you followed well enough. Your input solved my problem. I set a flag and I finally opened my eyes by only calling the highlightObjLink(findObj(1)); function

    Thanks ASchweti


Bookmarks

Posting Permissions

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