title: Clear Javascript Message Box from VBA
body: <p>In controlling a website (with VBA), and attempting to delete all of the selected items in a table, I get a Javascript pop-up which asks me if I really want to delete all of them (OK or Cancel). When this pops up, my vba code stops, and will not do anything else, until a human clicks the button.</p>
  
  <p>I have researched this quite a bit, and it seems that changing the onClick event for the HTML button would in theory work, but I have been unable to get it to work as of yet.  Below is the HTML code for the button, the subsequent Javascript code, and then my VBA code.</p>
  
  <p>HTML Button
  <div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;Delete:&amp;nbsp;&lt;input type="button" name="button_Delete" value="Delete" onclick="doDelete('c');"&gt;&amp;nbsp;&lt;span class="note"&gt;Deletes all selected charts.&lt;/span&gt;&lt;/p&gt; 
                                                            &lt;p&gt;Move to:&amp;nbsp;&lt;select id="select_Lists" name="select_Lists"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Javascript after HTML Button
  <div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;a href="javascript:doDeleteList('169', 'C');"&gt;Delete List&lt;/a&gt; |</code></pre>
  </div>
  </div>
  </p>
  
  <p>VBA Code to Delete all selected from HTML Table</p>
  
  <pre><code>Dim ieDelete as HTMLInputButtonElement
  SetieDelete = IE.Document.getElementsByName("button_Delte")(0)
  Sleep(500)
  ieDelete.removeAttribute("onClick")
  Sleep(500)
  ieDelete.setAttribute "onClick", "return true;"
  Sleep(500)
  ieDelete.Click
  </code></pre>
  
  <p>When running the VBA as is, it continues to bring up the Javascript message box.  I have attempted adding <strong>ieDelete.setAttribute "onClick", ""</strong>, but that ends up deleting the entire event, I was not able to do anything to it after that.</p>
  
  <p>And... For the record, I also saw a post describing another option, but I couldn't figure out how to use it in my scenario.  <a href="https://stackoverflow.com/questions/4664732/respond-to-website-message-box-by-automating-internetexplorer-with-vba">Respond to Website Message Box by Automating InternetExplorer with VBA</a></p>
  
  <p>Thanks in advance for the assistance.</p>