TreeView Support

Frequently Asked Questions

To show or hide an answer, click on the question.


Q. When the user clicks a folder, is it possible to automatically close other folders?

A. One of the principles of TreeView is that a branch should never collapse just because another branch is expanded. This is a rule in Windows Explorer, and it makes sense from an usability point of view. Here is an example of how annoying an "automatically-closing folders" design can be:

Suppose you want to buy a sofa at (don't let the Danish language intimidate you). Try to compare these two pages (they both show sofas): Internetbutik->Stuer->Sofa 3+2 pers->Stof and Internetbutik->Sovesofaer->Dobbelt sovesofa->Bomuld. And now try going between the two pages as an undecided shopper would.

Q. Can I show multiple trees in the same page?

A. No, that feature is not supported. If you try to do that it may work on some browsers, but will probably no look good or not work well on other browsers. The problem is the dynamic (DHTML) positioning of one tree relative to the other.

I have two suggestions: think of a common folder to be the root of your tree and put those two trees inside that root folder so you end up with just one tree. The other suggestion is to use a frameset and put each tree in its frame.

Q. How can I change the background color of the left frame (the one with the tree)?

A. If you are working with a frame-based layout, edit the CSS styles that are defined in the demoFramesetLeftFrame.html file. Follow the instructions in the comments.

Q. How can I change the size and color of the font used in the tree?

A. Edit the CSS styles for the block in the the file that hosts the tree (demo*LeftFrame.html, demoFrameless.html, etc.) Also see the Configuring Styles section in the TreeView Documentation.

Q. The standard + and - icons are difficult to see with a black background. Do you have alternate images?

A. Yes, this ZIP file has dark-background versions of the images.

Q. Why is the - icon not totally transparent?

A. The small square around the - icon (in ftv2mnode.gif) cannot be transparent; it needs to have some fill color for the line running in the background.

(Note that the last node does not have a line behind it, and so the "tt>- icon for the last node can be transparent. This is in the ftv2mlastnode.gif file.)

To correct the color matching, open the ftv2mnode.gif file in a graphics application and change the color to your background. If your background is made of a pattern or photo and not of a solid color, just pick a color that blends. After all, we are talking about a square that is 6 by 6 pixels and partially filled with the dash line.

Q. Highlighting does not work in Netscape 4.x. Is that a bug?

A. Support for dynamically changing CSS properties of objects other than layers is limited and incompatible in Netscape 4.x. The visual effects of highlighting were not implemented for that browser.

Q. Is it possible to position the tree with CSS attributes?

A. We are not sure. We tested positioning the tree anywhere in the page with margin-top and margin-left and it worked, but there may be cases where it doesn't.

Frames Or Their Absence

Q. Can I use the script without the frames?

A. Yes, you can. The only limitation is that in the old Netscape 4.x browsers the tree will be displayed with all nodes expanded. The reason for this is that combining absolute-positioned layers with general inline content in Netscape 4.x is impossible to do in a generic, reliable way. Frameless layout works great with Netscape 6 and later, all Mozilla versions, Internet Explorer 4 and later, and other browsers.

Q. The links open pages in a new window, not on the right frame. What am I doing wrong?

A. Make sure that the name of the right frame is basefrm. A TreeView requirement is that the name of the right frame is basefrm.

If the frame has the correct name but are still having problems, make sure that you are using the correct syntax for the gLnk function. See the Manually Building Tree section in the TreeView Documentation for more information.

Q. How can I have node links open in the right frame, but folder links open in a different frame (or window)?

A. This requires making some changes to the code. The instructions below are for the case where you want the pages to load on the left frame, but can be easily adapted for other types of target. Open ftiens4.js in a text editor and find the following line in the linkFolderHTML function:

    docW = docW + "<a href='" + this.hreference + "' TARGET="basefrm" "

and replace it with this line:

    docW = docW + "<a href='" + this.hreference + "' TARGET=_self "

Make sure you keep the space between the _self and the double quote.

Q. My site will have three frames, can I still use the Treeview?

A. Yes, you can have many frames on a page. Just be careful with the names of the frame containing the tree and the frame containing the destination pages or files.

Q. Can I make the tree menu control simultaneously load pages in two frames?

A. Yes, it is possible to make pages load in two different frames when the user clicks on a link in the tree. One of those destination frames will be the basefrm that TreeView currently uses. Let's call the other destination frame secondframe. So, you will need the tree to cause the loading of a new page in the basefrm frame (which is the the basic functionality), and then you will need the loading of the page in the basefrm to cause another page to load in secondframe. That is, you will need a JavaScript function that loads a page in secondframe. You must associate the onLoad event for the basefrm with the function you write. You will probably want to define the JavaScript function in the header section of the frameset HTML file.

Q. How can control the new window that pops up when I click in a node?

A. You can do things like removing the menus, toolbars, and so on. You can also change the window dimensions. However, it requires that you call a JavaScript function. You can see an example in the Advanced Controls demo.

Removing the Link

Q. Can I remove the small link above the JavaScript tree menu?

A. You cannot simply remove the link, because the script will not work properly. But you can upgrade to a paid version that does not show the link. The functionality is exactly the same between the two versions; the only difference between them is the presence of the link.

To upgrade to the paid version, you can visit the purchase page. If you just want to know the price, or to get more information, but are not yet ready to upgrade, follow the link to the purchase page anyway; it will not immediately start a transaction. The paid version includes instructions for removing the link.

Q. I am building a corporate or institutional web site. Can I still use the free version?

A. Corporate users are encouraged to upgrade to the paid version (at the purchase page). If the site you are building is not public, in other words it is on an intranet, then you are strongly recommended to upgrade to the paid version.

Programmatic Manipulation

Q. My cookies expire at the end of a session. How can I recreate the tree the next day, after restarting the computer.

A. You can do that by changing the expiration date of the cookie. There is no configuration option for this, so you will have to make a change to the engine script. Open ftiens4.js in a text editor and search for function SetCookie. In the function, you will find the following line:

    var expires = (argc > 2) ? argv[2] : null;

Change this line to read:

    var expires = new Date("1/1/2030");

The tree engine will now have a record of the collapse/expand state of the tree even after you close the browser.

Q. When loading, can the tree open more folders than the default/root folder?

A. Yes, if there are one or two other folders that you would like to also show expanded, use the same technique employed in the Advanced Controls demo for the "Open Flags Folder" menu option.

Instead of putting the function call in the button, put it in the tree page, after the call to initializeDocument().

Q. The instructions use xID to identify nodes. Is it possible to determine the xID of the current node?

A. Yes, for those trees that are configured with HIGHLIGHT=1, there is a variable that can be used to access that information. The name of the variable is lastClicked and, in terms of the document object model, it becomes a member of the window where the tree is being shown. This variable points to the node object, from which you can get the xID value.

For the case where the tree is being shown in a frame-based layout, this would be a function defined in the parent, frameset page, which would return the ID of the selected node (assume that frame containing the tree is called leftFrame):


    function currentNodeID() {

       if (typeof window.leftFrame.lastClicked == "undefined")

          return null;

       return window.leftFrame.lastClicked.xID;



Q. Is it possible to add a link or a button that reverts the tree to its initial state?

A. Yes. The Advanced Controls demo shows this behavior. If you download TreeView, you will get the code for this demo.

Q. If users link directly to a page in the middle of the tree, is it possible to scroll to the corresponding node in the tree?

A. Yes. The Advanced Controls demo shows this behavior. If you download TreeView, you will get the code for this demo.

Working with a Database

Q. Can I use the Treeview tree menu to show the contents of a database?

A. Yes. Please check the TreeView Documentation page.

Q. I read the instructions for server-side code, but would prefer a fully working example. Do you have such code?

A. Yes, the free download includes such an example. However, it will likely not fit your needs. A tree created dynamically by the server is functionality that is very specific for each project. What happens when the user clicks the folder? What happens when the user clicks the link? Are the files listed on the right frame or inside the folders? And so on. Moreover, answers to these questions will change from a frame-based to a frameless layout.

Besides the demo, there are also two products that offer examples of server side code, which you may want to purchase. One is Favorites Manager and the other is Web File Browser.

Q. Is it possible to generate an XML file from the database and configure the tree using the XML file?

A. No, configuration files in XML are not supported. Here is what would happen if the TreeView configuration files were written in XML:

  • The size of the files to be downloaded by the visitor would increase because an extra module of code would be needed to parse the XML file.
  • The existence of that parsing phase would also impact the speed at which the tree is built because no matter how fast the (JavaScript written) XML parser is, it is never as fast as the internal JavaScript interpreter itself.
  • The server-side developer would still have to learn about nodes, links, targets, and all the concepts involved with Treeview construction; XML would not change that.
  • Validation of tree configuration files could be done outside the browser by any XML validating application (that app would also be given a Treeview schema). However, most of the errors that can be made when configuring the tree would not be caught, because they are not syntactical or range errors.
  • It would be much more difficult to extend functionality, because the XML configuration files store only data, not code.

Problems with Demos

Q. When I try demos online, even ones that don't require cookies, my browser warns about cookies. Can you explain?

A. Yes, because of the way our hosting accounts configure their Web servers, when files such as images are requested, cookies are set in your browser. Even when the demos are run from your local machine, the pictures are coming from our Web site. Naturally, once you configure the tree to link to your own pages this problem will disappear and no cookies will be set in the browser by the script.

Q. I am using NS6.x+ but I cannot see the TreeView demos. Is there something I can do?

A. Yes, check the settings on your firewall and antivirus software. Some of those utilities have "privacy" options that disable JavaScript, DHTML, or cookies (which are only required with some special tree configurations). These "privacy" settings will affect any advanced browser applet, not just TreeView, and may be more apparent in Netscape than in Internet Explorer.

Q. The script runs fine on my local hard drive. But when I copy the files to my hosting account, they don't work. Why?

A. In some cases transferring FTP files to another machine changes the capitalization of the names of files. If that happens and if the web server is sensitive to capitalization, the tree will not work. In that case simply correct the capitalization of the names of the files in the remote machine to make them equal to the ones in the hard drive.

If the server in question is Geocities, then the problem is because of their behind-the-scenes JavaScript that places ads on the pages. This code conflicts with the TreeView code that checks the JavaScript Tree Menu top link. If you purchase the registered version of TreeView (that does not have the top link) this will not happen.


Q. The tree expands and collapses, but when I click a link I don't get the intended results?

A. Is the correct document appearing, but it is appearing in an unexpected frame or window? If so, read the generic instructions about configuring targets in the TreeView Documentation and check for possible problems in the "Questions About Frames Or Their Absence" section of this FAQ.

Is the correct document not appearing? If it is not, the best strategy for understanding what is wrong with your target URLs is to repalce the tree with a simple list of hyperlinks, just for testing. Keep the same framesets (if you have them) and the same HTML pages, but comment out the code related to the tree and replace it with a simple list of links. Use the same URLs and the same targets that you specify in the configuration of the tree. Then by testing with this simple list of links, you can determine what is causing the problems.

Some examples of issues people have encountered include:

  • When links to Microsoft Word documents don't open, it is usually caused by the configuration of the browser and/or the configuration of Windows.
  • When links of the type file://... don't open, it is usually caused by the client system not having permission to access that file directly, without going through the web server.
  • When subsequent activations of similar file://... links fail to register in the history of the browser, it may be because the only difference between those file system links is a query string parameter.

Q. I want to use HREFs like javascript:functionname(...), but it doesn't work. What am I doing wrong?

A. If you are using the frame-based layout, your function needs to be defined in the HTML for the frame set (for example, demoFrameset.html) and the argument given to the gLnk or gFld needs to look like this:


Make sure to verify the construction of your strings. For example, make sure to properly escape quote characters. If you do not think the error is related to quotes or the syntax of the function HREF, you can try the following:

  • Hover your mouse over the folder or document link, and look at the status bar of the browser. If the HREF value looks incomplete, you have a problem with quotes.
  • Click the folder or document link. If you see the message "object expected", the problem is related with finding the function that you want to associate with the click.

Q. The icons appear one-by-one, even though they are the same image. Are they being cached?

A. Yes, they should be. If you enabled automatic caching in IE they will be cached, and expanding a folder will be very fast. However, if the server is not configured to send to the browser information about the version of the image, IE will not cache the image. This is not very common, but it does happen. You can test if the server is correctly configured by doing a right-mouse-button click over the folder or document icon, selecting Properties, and looking at the created and modified dates. If they say "Not Available" the server is not correctly configured.

If you have access to the Web server configuration, you should configure it to enable caching. The actual instructions to do this depend on the type of server. For IIS check this article. For other servers including Apache, see this article and search for Implementation Notes - Web Servers.

If you don't have access to the server configuration (that is you are using a Web-hosting company or something), you should contact support and even quote this Question & Answer. They should be able to fix this problem.

A simpler, but last-resort, solution is to set the TreeView option BUILDALL = 1 for your tree. This will, however, impact the time it takes to create large trees, and can even cause the browser to show an error message if your tree has hundred of nodes.

Q. Some icons are missing from my tree. Can you help?

A. Are they still missing if you refresh the window or frame? If they reappear after a refresh, or when you use the BUILDALL = 1 option, then see the above question. If the icons are not showing up no matter what you do, then the issue could be that the image tag used by the tree is not pointing to a valid icon image. The best way to figure out this kind of problem is to use the right mouse button to inspect the properties of the image (even though the image area is empty, the HTML image tag is still there, so you can right-mouse-click it). Copy the address of the image shown in the properties into the address bar of another browser. Because this will fail, you should now have enough information to fix the problem. It is either a missing icon image, a corrupted icon image, or an incorrect setting of the ICONPATH variable.

Q. My folders don't collapse and expand or I see an error message when I click on a folder icon. What can I do?

A. You probably introduced an error in the JavaScript code. Check your configuration file (demo*Nodes.js) carefully. Look for potential instances of invalid strings. For example, if a string is delimited by the single quote character (') and the same character also appears inside the string, the string will be invalid. In that case, the solution is to escape the single quotes (to precede with a backslash) in the text of the strings. For example: 'John's Pub' is wrong and 'John's Pub' is right.

However, the problem may not be related with strings. The best way for you to find the error that you may have introduced is to make small changes and check them often. Start with the download code that worked fine for you. Then make one small change and check again. Repeat this small-steps process until you make the small change that re-introduces the original problem. Now that you know what is causing the problem you will probably know how to fix it.

Note that one small change that will break the free version of the script is the removal of the top link. If you remove this link the script will not work.

Q. Why do I get "Object doesn't support this property or method" (or "isOpen is null or not an object")?

A. There are a number of cases when this can happen.

One scenario is if you are not using external ids (node.xID=...) and are setting PRESERVESTATE = 1 and were making changes to the structure of the tree. After a reload, the tree tries to open a folder using an internal ID, but that ID may not be pointing to a folder anymore. For example, if the cookies are trying to open folder 5, but node 5 is now a link, not a folder. The solution in this case depends on how the structure of the tree changed. If it was because you edited the configuration file manually, then all you need to do is close the browser to reset the cookies (they are session cookies). If the structure was being changed by a server side application then the solution is to use external IDs. (See the Working with Node IDs in the TreeView Documentation.)

If you are already using external IDs and are seeing this message, then check that all nodes do have an external ID assigned to them, including the root node (foldersTree.xID = ...).

Q. I have server-side code that tries to generate a tree dynamically, but it is not working. Can you help?

A. First read the instructions on Creating from a Database and also make sure you study carefully the code that comes with the Database demo, even if you are using a language other than ASP.

Many things can go wrong with code to dynamically build trees. Since all implementations are different, all I can do is give some generic instructions to help debugging your code:

If the browser is showing error messages, the line number will probably be referring to the source HTML of the tree frame. In the browser, do a view source for the left frame. Look carefully at the contents of this file. The section that will probably giving you errors is the one that configures the tree. The section that starts with foldersTree = ... and then follows with insDoc and insFld instructions. Compare this section with the contents of a configuration file such as demoFramesetNode.js. One common error is that new line characters may be missing. Don't use <br>! This is JavaScript, not HTML.

It is also very important that you verify the construction of your strings. Look for potential instances of invalid strings. For example, if a string is delimited by the single quote character (') and the same character also appears inside the string, the string will be invalid. In that case, the solution is to escape the single quotes (to precede with a backslash) in the text of the strings. For example: 'John's Pub' is wrong and 'John's Pub' is right.

If you still didn't catch the error, proceed this way: copy the contents of the "view source" that were dynamically generated into a new HTML file. Use this HTML as the new source for the left frame and reload the whole thing. Now you are debugging plain HTML/JavaScript and have eliminated the server-side scripting. If the database was outputting a big tree you may want to start removing nodes from this file until the error goes away. That will help you understand the error in the static HTML file you saved, and consequently in the server-side scripts that created it in the first place.

Q. I purchased the registered version. However, when I remove the top link, the tree doesn't work.

A. Most likely (based on past experience) you have just made some small mistake along the download and install process. Please try the following steps:

  1. Create a new, empty, local directory. Do not do this test on a remote server. A common cause of the problem you are seeing is the caching of the old ftiens4.js by servers, firewalls, and browsers.
  2. Empty the cache of your browser and close all your browser windows.
  3. Download the latest free from
  4. Extract the files to the new directory.
  5. Test demoFrameset.html, it should show the top link and it should work fine.
  6. Now remove the block of HTML surrounding the JavaScript Tree Menu link (including any enclosing DIV or TABLE blocks, if they exist.)
  7. Test again and confirm that the tree doesn't show anymore.
  8. Now copy from your copy of the file ftiens4.js over the one in this new directory. The "would you like to replace" message given by Windows should show a slightly smaller size of the paid ftiens4.js. Say yes to overwrite.
  9. Test the demo again. It should now work fine.

If the steps above lead to a correct result, they should help you find what you may have done wrong with your other files. If, however, at the end of those steps the tree is not showing, please contact me.

Q. I am using external IDs and PRESERVESTATE, but the state is not being preserved. Am I using invalid IDs?

A. Yes, that would be my guess. Some characters cannot be used in the strings of the xID attribute because they are reserved as separators in the browsers's cookie string: See the Working with Node IDs section of the TreeView Documentation.

Q. I get parse errors in FireFox 2.0 due to a non-standard position:block; CSS value.

A. This was fixed in the 26 Sep 06 version of ftiens4.js. If you are using a version of TreeView prior to this, the easiest thing to do is to simply remove the offending text. Removing the non-standard code has no effect on the operation or appearance of the TreeView. Open ftiens4.js in a text editor and search for position:block;. Remove this text (and the space in front of the text). The line should now read as follows:

    docW = "<div " + idParam + " style='display:block;'>"

Q. In Internet Explorer, MS Word files open in the browser for me. How can I get them to open in MS Word?

A. Conventional wisdom says that you should be very careful when attempting to have an HTML document (in a browser) control something that happens on the client machine. And controlling the behavior of other applications when someone clicks on a link falls into this category. The reason you need to be careful is that, depending on your situation, you may end up coding behavior that an end user's browser or operating system cannot perform. So, for this reason, many people shy away from coding any behaviors that are not cross-platform. I think this is probably one of the main reasons why Word documents are not very common on the Web. Of course, in reality, it gets even more complicated because different versions of the same platforms behave differently (for example, Windows 98 vs. Vista and so on) and you have application versioning issues. However, if you want to do this, the following resource looks useful:;en-us;Q178222

Browser Support

We test on the following platforms:

  • Linux Fedora Core 4
  • Macintosh OSX 10.3
  • Macintosh OSX 10.4
  • Windows 98
  • Windows 2000 Professional
  • Windows Vista RC1

We test TreeView on the following browsers:

  • Camino 1.0
  • Firefox 2.0b2
  • Netscape 7.2
  • Explorer 5.2
  • Konqueror 3.4.0-5
  • Opera 8.5.0
  • Explorer 6.0
  • Mozilla 1.6
  • Opera 9.0
  • Explorer 7.0 RC1
  • Mozilla 1.7.12
  • Safari 1.2
  • Firefox 1.5
  • Netscape 4.78
  • Safari 1.3
  • Firefox 2.0b1
  • Netscape 6.2.3
  • Safari 2.0

Note: On the Konqueror and Safari browsers, there is a problem with
using the TreeView in a frame-based layout. The frame-less layouts work without
a problem. However, in the frame-based layout, while the loading of the first
document node you click on works fine, subsequent clicks on document nodes do
nothing. If the Konqueror and Safari browsers are important to you, please use
a frame-less layouts.

Contact Us

If you don't find the answer to your question here, please email your question to us at .

Note: We try to answer all emails within three business days. If you send an email and do not receive a reponse, please check your Bulk email folder or your Spam filter to make sure our response is not being filtered out. If you experience issues with the GubuSoft email addresses, feel free to email our backup email address at . Thank you!