YUI –面板关闭
在面板外部单击以将其关闭
var treePanel = new YAHOO.widget.Panel(...); function isInsideTreePanel(clicked_element) { var current_element = clicked_element; while(current_element && current_element != document.body) { if (current_element == treePanel.element) { return true; } current_element = current_element.parentNode; } return false; } function onDocumentMouseDown(e) { if (treePanel.cfg.getProperty('visible')) { if (!isInsideTreePanel(e.target)) { treePanel.hide(); YAHOO.util.Event.removeListener(document, onDocumentMouseDown); } } } treePanel.show(); YAHOO.util.Event.addListener(document, 'mousedown', onDocumentMouseDown, null);