JavaScript Function to Expand All Sections in Document on the Web

Author: Tripp W Black

Created: 03/20/2001 at 03:49 PM

 

Category:
Notes Developer Tips
Forms/Subforms, JavaScript

Problem:

The formula @Command([SectionExpandAll]) allows Notes users to expand all sections in a document. This formula is not supported for web clients. How can this same functionality be achieved for web clients?

Solution:

To create this functionality on the web, create a JavaScript function in the JSHeader event of the form with the following code:


function expandAll() {
var secList="";

// Loop through all Anchors with _Section in Anchor.name
for (var i=0; i<document.anchors.length; i++) {
var a=document.anchors[i].name;

if (a.indexOf('_Section') != -1) {
// Found a section. Store its # in secNum
secNum=a.substring(a.length-1);

if (secList=="") {
// this is the first Section found begin the list of sections
secList=secNum;
} // end if

else {
// append additional Section numbers to list of sections
secList=secList+","+secNum;
} // end if...else

} // end if a.indexOf
} // end for loop

// Check for 'stop' in QueryString to prevent infinite loop (this is for onLoad execution)
if (window.location.search.indexOf('Stop') == -1) {
window.location=window.location.pathname+"?OpenDocument&ExpandSection="+secList+"&Stop";
}


} //end function


Then call the function "expandAll()" from the Form's onLoad event, a Form Action or Action Hotspot.

expandAll()

Supporting Information:

This script does not work for nested sections. When nested sections are collapsed, not all of the section anchors display.


Related Documents:

Can All Sections in a Document be Expanded or Collapsed at Once Through a URL?
Document #: 165840

(C) Copyright 2001 Lotus Development Corporation. All rights reserved.

previous page