title: display a window alert on click
body: <p>I'm not sure how to do this, and can use some advice.</p>
  
  <p>I created a custom button on a standard page layout, and when the user clicks it, I want to check if the user has contacts in this object.  </p>
  
  <p>If he doesn't, I want to display an alert- "please add contacts" and and return him to his current <strong>STANDARD</strong> page. Otherwise, I want him to get to a new VF page that is already written.
  I'm not sure how to do this...</p>
  
  <p>HALP!</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;apex:page standardController="MY_List__c" extensions="MYListExtension" &gt;
  &lt;apex:form &gt;
  
             &lt;script&gt;
                  var hasContact = {!totalContacts};
                  if(hasContact == 0 ){
                      alert('Please add contacts!'); 
                      window.location ="/" + {"!theListId"};                    
                         }
                       else{
                            window.location = "/MYListSend?id=" + {"!theListId"};
                  }
  
              &lt;/script&gt;
  
              &lt;/apex:form&gt;
  &lt;/apex:page&gt;
  </code></pre>