View Full Version : Smart Folding Menu tree Problem With FireFox

03-14-2005, 10:44 PM
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 :


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 !

03-14-2005, 10:47 PM
Oh I forgot something.

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

Thanks !

03-16-2005, 06:51 AM
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:

<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"){
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){
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

if (ns6||ie4){

May or may not help.