How to add the Toggle Legend map toolbar button

This command will cause the Legend to toggle between a collapsed and expanded state.
IMPORTANT NOTE: the function on this page is added as a custom command button to the map toolbar. See that article for how to add such a button.
Configure the button for the target Web Layout as follows:
Under the Settings tab, enter the following (you can change these values if you wish):
    Command name: Toggle Legend
    Name to display in the interface: Toggle Legend
    Tool tip to appear on hover: Toggle Legend for this map
    Description to appear on the status bar: Toggle Legend for this map
    URL to an image for enabled state: ../stdicons/icon_back.gif
    URL to an image for disabled state: ../stdicons/icon_back_disabled.gif
Under the Additional Parameters tab, enter the following under Script to invoke:
var mapFrame = GetMapFrame();

mapFrame.minInfoWidth = 200;

Note that 200 is the width in pixels to which the Legend will be expanded after being collapsed. You can change this value if you wish.

[Last updated for version 3369 (07/2016)]