Results 1 to 3 of 3

Thread: Smart Folding Menu tree Problem With FireFox

  1. #1
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Smart Folding Menu tree Problem With FireFox

    Hi ! First, congratulations for these great scripts ! It is really usefull !

    I have a problem with Smart Folding Menu tree. Everything works fine in IE but with FireFox, most of the time, the nodes are frozen, they do not open... It does not happen all the time.... Here is an example site :

    http://demo.smartfactory.ca/modules/smartfaq/

    If it works for you, try navigate on the site a bit an then come back to the SmartFAQ. It will do it at some point.

    When the node freezes, if I enabled the Javascript Console, I get one of these errors :

    error : foldercontent has no propertiers
    foldercontentarray[openresults[i]].previousSibling.previousSibling.style has no properties
    I can reproduce this on the very example at Dynamicdrive so the problem is not vert likely to come from my implementation of it.

    Here is a discussion I had with a friend, maybe it could help some of you guys :
    Brian: here's the thing, the error occurs on this line:
    var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
    Brian: which says, take the current element (cur)
    Brian: look the next element on the same level as the current element, then look at the next element after that (so 2 elements away from the current one)
    Brian: but if you look at the html
    Brian: 2 elements away is the next li tag, not the UL tag
    marcan [SmartFactory.ca]: ahhh !
    marcan [SmartFactory.ca]: how can I fix that ?
    [...]
    Brian: ok the more I look at the code, the more I think it to be a browser bug. On one load cur.nextSibling.nextSibling returns null, on the next it returns the UL element (as it should)
    [...]
    Brian: the code should work fine in FF and IE as written. I figured out that Gecko browsers put a TEXT element in-between the LI and the UL, which is why we move two down, instead of just one
    Any help would be greatly appreciated :-)

    Thanks !

  2. #2
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh I forgot something.

    When the nodes freeze, If I refresh the browser, it will work again.

    Thanks !

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please include a link to the script on DD in the future: http://dynamicdrive.com/dynamicindex1/navigate1.htm

    I was able to see the error in Firefox after hanging about on your page for a few moments. Can't quite say what the problem is exactly yet though, except the error indicates the problem is within the persistent cookie code (Step 4). Removing it will definitely fix the problem, if that's an option. The "freezing" is simply due to FF encoutering a JavaScript error, halting the functioning of the script.

    A shot in the dark, but try replacing your persistence cookie code (Step 4) with the below modified version, which merely activates the persistence after the page has loaded:

    Code:
    <script language="JavaScript1.2">
    <!--
    
    function get_cookie(Name) {
    //Get cookie routine by Shelley Powers 
      var search = Name + "="
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        // if cookie exists
        if (offset != -1) { 
          offset += search.length
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1) end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end))
          }
       }
      return returnvalue;
    }
    
    var foldercontentarray=new Array()
    var c=0
    
    if (ns6){
    for (i=0;i<document.getElementsByTagName("UL").length;i++){
    if (document.getElementsByTagName("UL")[i].id=="foldinglist"){
    foldercontentarray[c]=document.getElementsByTagName("UL")[i]
    c++
    }
    }
    }
    function doonload(){
    if (get_cookie(window.location.pathname) != ''){
      var openresults=get_cookie(window.location.pathname).split(" ")
      for (i=0 ; i < openresults.length ; i++){
        if (ns6){
        foldercontentarray[openresults[i]].style.display=''
        foldercontentarray[openresults[i]].previousSibling.previousSibling.style.listStyleImage="url(open.gif)"
        }
        else{
        foldinglist[openresults[i]].style.display=''
        document.all[foldinglist[openresults[i]].sourceIndex -1].style.listStyleImage="url(open.gif)"
        }
      }
    }
    }
    
    if (ns6||ie4){
    var nodelength=ns6? c-1 : foldinglist.length-1
    var nodes=new Array(nodelength)
    var openones=''
    }
    
    function checkit(){
      for (i=0 ; i <= nodelength ; i++){
        if ((ns6&&foldercontentarray[i].style.display=='')||(ie4&&foldinglist[i].style.display==''))
           openones=openones + " " + i
      }
      document.cookie=window.location.pathname+"="+openones
    }
    
    if (ns6||ie4){
    window.onload=doonload
    window.onunload=checkit
    }
    //-->
    </script>
    May or may not help.

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
  •