有高手知道吗?
Javascript源码如下:
//----------------------------------------------------------------------------
// Code to determine the browser and version.
//----------------------------------------------------------------------------function Browser() {
 
 var ua, s, i;  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;  ua = navigator.userAgent;  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }  // Treat any other "Gecko" browser as Netscape 6.1.  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}var browser = new Browser();//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------var activeButton = null;/* [MODIFIED] This code commented out, not needed for activate/deactivate
   on mouseover.// Capture mouse clicks on the page so any active button can be
// deactivated.if (browser.isIE)
  document.onmousedown = pageMousedown;
else
  document.addEventListener("mousedown", pageMousedown, true);function pageMousedown(event) {  var el;  // If there is no active button, exit.  if (activeButton == null)
    return;  // Find the element that was clicked on.  if (browser.isIE)
    el = window.event.srcElement;
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);  // If the active button was clicked on, exit.  if (el == activeButton)
    return;  // If the element is not part of a menu, reset and clear the active
  // button.  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}[END MODIFIED] */

解决方案 »

  1.   

    function buttonClick(event, menuId) {  var button;  // Get the target button element.  if (browser.isIE)
        button = window.event.srcElement;
      else
        button = event.currentTarget;  // Blur focus from the link to remove that annoying outline.  button.blur();  // Associate the named menu to this button if not already done.
      // Additionally, initialize menu display.  if (button.menu == null) {
        button.menu = document.getElementById(menuId);
        if (button.menu.isInitialized == null)
          menuInit(button.menu);
      }  // [MODIFIED] Added for activate/deactivate on mouseover.  // Set mouseout event handler for the button, if not already done.  if (button.onmouseout == null)
        button.onmouseout = buttonOrMenuMouseout;  // Exit if this button is the currently active one.  if (button == activeButton)
        return false;  // [END MODIFIED]  // Reset the currently active button, if any.  if (activeButton != null)
        resetButton(activeButton);  // Activate this button, unless it was the currently active one.  if (button != activeButton) {
        depressButton(button);
        activeButton = button;
      }
      else
        activeButton = null;  return false;
    }