title: How to add message box for buttons in html using javascript
body: <p>I'm trying to add the message box (JavaScript) when click button in client Application. </p>
  
  <p>when Click "YES" will trigger the controller and Click "NO" will stay the view.</p>
  
  <pre><code>        &lt;div&gt;
              &lt;button type="button" onclick="location.href ='@Url.Action("PreviewBills","Sites",new {id = Model.Id},null)'"&gt;
                  Preview Invoices
              &lt;/button&gt;
         &lt;/div&gt;
  </code></pre>
  
  <p>and I tried to apply the following code, but msgbox doesn't response.</p>
  
  <pre><code>
  @{
      ViewBag.Title = "Site";
  }
  &lt;div style="float:left;width:24%;height:100%;"&gt;
  
  
      &lt;fieldset&gt;
  
  
              &lt;button type="button" onclick="preview()"&gt;
                  Preview Invoices
              &lt;/button&gt;
  
      &lt;/fieldset&gt;
  
  &lt;/div&gt;
  
  
  
  &lt;script&gt;
      function preview() {
          var r = confirm("Please confirm.");
          if (r == true) {
  
              location.href ='@Url.Action("PreviewBills","Sites",new {id = Model.Id},null)';
          } else {
              //do nothing
          }
      }
  &lt;/script&gt;
  
  </code></pre>
  
  <p>Any guide or induction will be appreciated</p>