title: HtmlUnit webscraping Anchor tag with dropdown link that has JavaScript
body: <p>Is it possible to click on a link using HtmlUnit when that link has a dropdown list of links when you mouseover the initial link. If you click the initial link nothing happens except for you get list of links that drop down when you mouse over.  I would like to click one of the drop down links and grab the web page that is associated with that link.  </p>
  
  <p>The problem seems to be that the Anchor has JavaScript and also it is a drop down list.  If the Anchor did not have JavaScript and drop down then I would not have any problems.  </p>
  
  <p>Here is the pertinent JavaScript Code:</p>
  
  <pre><code>&lt;script language='JavaScript' type='text/javascript'&gt;
  &lt;!--
  function mmLoadMenus(){
   window.mm_menu_0805151542_0 = new Menu("root",211,23,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#056CB9","#014D98","left","middle",3,0,1000,-5,7,true,false,true,2,true,false);
    mm_menu_0805151542_0.addMenuItem("View&amp;nbsp;Tax&amp;nbsp;Sales","window.open('TCTaxSaleBrief.asp', '_blank','width=800,height=580,scrollbars=1,resizable=yes,top=50,left=100');");
    mm_menu_0805151542_0.addMenuItem("Registration&amp;nbsp;Renewal&amp;nbsp;Reprint","window.open('vrRenewal.asp', '_blank','width=800,height=580,scrollbars=1,resizable=yes,top=50,left=100');");
    mm_menu_0805151542_0.addMenuItem("Drivers&amp;nbsp;License","window.open('http://www.dds.ga.gov/', '_blank');");
    mm_menu_0805151542_0.addMenuItem("Online&amp;nbsp;Tag&amp;nbsp;Renewals","location='../TaxCommissioner/TagRenewal.html'");
     mm_menu_0805151542_0.hideOnMouseOut=true;
     mm_menu_0805151542_0.bgColor='#CCCCCC';
     mm_menu_0805151542_0.menuBorder=0;
     mm_menu_0805151542_0.menuLiteBgColor='#FFFFFF';
     mm_menu_0805151542_0.menuBorderBgColor='#015BA7';
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is the pertinent Anchor:</p>
  
  <pre><code>&lt;a href="#" name="link11" class="nav" id="link10" onmouseover="MM_showMenu(window.mm_menu_0805151542_0,104,0,null,'link11')" onmouseout="MM_startTimeout();"&gt;Online Services&lt;/a&gt;&lt;br /&gt;
  </code></pre>
  
  <p>Here is the snippet of Java Code that I am using to make this work. </p>
  
  <pre><code>WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10);
      String webPage="http://website.html";
      try {
          HtmlPage taxComPage = webClient.getPage(webPage);
          HtmlElement htmlElement = taxComPage.getDocumentElement();
              //HtmlAnchor anchor = taxComPage.getAnchorByText("View Tax Sales");
          //HtmlAnchor htmlAnchor = taxComPage.getHtmlElementById("link10");
          HtmlAnchor anchor = taxComPage.getAnchorByText("Online Services"); 
  
          HtmlPage page = anchor.click();
      }catch
  </code></pre>
  
  <p>If it is the case that HtmlUnit does not work with JavaScript please let me know!</p>
  
  <p>Thanks  </p>
  
  <p>I understand that there is this function called: mmLoadMenus() which has text that is displayed when moused over but I having issue with how is this function associated with the anchor.  In the anchor there is something called MM_showMenu.  What is this MM_showMenu, who created it, is this a JavaScript keyword, I don't see it being defined anywhere. I have searched the whole page, the only place it is mentioned is in the anchor.  It seems to be some type of a function with parameters of: window.mm_menu_0805151542_0,104,0,null,'link11' being passed to it.  The only connection that I can make between  function mmLoadMenus() and the anchor is that the anchor has mm_menu_0805151542_0 in it.  I am not that well versed in JavaScript maybe that is why I am not making a strong connection with the JavaScript function and the anchor.   </p>