Sets the open state (true or false) of the entry specified by entryNo. If state is true, setEntry will make sure all parents of the entry are open as well. Returns true if the menu has been changed and needs refreshing.
Sets the open state (true or false) of the entry that links to the URL specified by theURL. theURL must exactly match the URL used when the entry was defined. If state is true, setEntry will make sure all parents of the entry are open as well. Returns true if the menu has been changed and needs refreshing.
Searches the menu for an entry. Returns -1 if no matching entry was found.
Parameter | Description |
---|---|
value | The value you are looking for. This should be the same data type as the property being searched on. |
property | A string value containing the name of the MenuEntry property that you want to match. If no property is supplied, "url" is assumed. |
matchType | This can take three values; "exact", "left" and "right". If anything else is supplied, "exact" is assumed. This determines how string values of different lengths are compared. If matchType is not "exact", findEntry will align the strings as indicated by matchType and will attempt to match the shortest string with the corresponding segment of the longer string. |
startPos | Determines the entry to start searching from. The default is 0. |
findEntry searches through all menu entries until it finds one where the specified property contains the value specified. In addition to the standard properties described below, findEntry will also search any custom properties that you have added to the entries. findEntry searches through the entries in ID order, starting at the ID specified by start. This will generally be the order in which you have added the entries to the outline but, if you have removed entries along the way, it may not.
You can, for example, find the entry for the current page with
var entryID = parent.theMenu.findEntry(thisURL, "url");
where thisURL is the URL of the current page. If using an exact search, the URL supplied must exactly match the URL used define it entry. A more generic approach would be to use the location.pathname JavaScript property with a right search:
var entryID = parent.theMenu.findEntry(location.pathname, "url", "right");
Or, you could find all entries that match a particular condition:
var eID = parent.theMenu.findEntry(true, "isopen", "exact", 0); while (eID >= 0) { // Do something with entry ID alert('The entry titled "' + parent.theMenu.entry[eID].text + '" is open.'); // Then find next match eID = parent.theMenu.findEntry(true, "isopen", "exact", eID + 1); }
Click here to try it.