title: How to get the return value from a confirm popup alert
body: <p>I am trying to make a popup alert.
  The problem with it is that I can't get the return value.
  It is because the close function is created in the function itself.</p>
  
  <p>Is there a way to return the value?</p>
  
  <p><a href="http://jsfiddle.net/dccb2fu0/1/" rel="nofollow">JSFiddle</a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;button id="div" onclick="popup()"&gt;START&lt;/button&gt;
  
  &lt;div id="popUp"&gt;
    &lt;div id="popUpHeader"&gt;
    &lt;/div&gt;
    &lt;div id="popUpBody"&gt;
      &lt;h1 id="title"&gt;&lt;/h1&gt;
      &lt;p id="txt"&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;button id="popUpButton"&gt;OK&lt;/button&gt;
    &lt;button id="popUpYes"&gt;YES&lt;/button&gt;
    &lt;button id="popUpNo"&gt;NO&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function popup() {
    var a = popupbox('Warning', 'Are you sure?', 'yesno');
    alert(a);
  }
  
  function popupbox(title, txt, type) {
    document.getElementById('popUp').style.display = 'block';
    document.getElementById('title').innerHTML = title;
    document.getElementById('txt').innerHTML = txt;
  
    if(type == 'ok') {
      document.getElementById('popUpButton').style.display = 'block';
      document.getElementById('popUpButton').onclick = function () {
        document.getElementById('popUp').style.display = 'none';
        document.getElementById('overlay').style.display = 'none';
      }
    } else {
      document.getElementById('popUpYes').style.display = 'block';
      document.getElementById('popUpNo').style.display = 'block';
      //return true;
      document.getElementById('popUpYes').onclick = function () {
        document.getElementById('popUp').style.display = 'none';
        return true;
      }
      document.getElementById('popUpNo').onclick = function () {
        document.getElementById('popUp').style.display = 'none';
        return false;
      }
    }
  }
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>#popUp {
      display: none;
      position: absolute;
      top: 25%;
      left: 50%;
      margin-left: -100px;
      background: white;
      width: 250px;
      min-height: 100px;
      border-radius: 4px 4px 4px 4px;
      border: 1px solid #888;
      border-top: 5px solid black;
      box-shadow: 0px 2px 10px #999;
      z-index: 9999;
      text-align: center;
  }
  #popUpBody {
      margin: 3px 0px 3px 0px;
  }
  #popUpBody h1 {
      margin-top: 10px;
      font-family: 'Roboto', sans-serif;
      font-size: 15px;
  }
  #popUpBody p {
      padding: 10px 10px 0px 10px;
      color: black;
      font-family: 'Roboto', sans-serif;
      font-size: 15px;
      margin: 0 auto;
      /*ADJUST HEIGHT ACCORDING CONTENTS*/
  
      margin-bottom: 50px;
  }
  #popUpButton {
      display: none;
      position: absolute;
      bottom: 0px;
      width: 60px;
      margin: 10px 0px 10px 60px;
      padding: 5px;
      font-size: 14px;
  }
  #popUpYes {
      display: none;
      position: absolute;
      bottom: 0px;
      width: 60px;
      margin: 10px 0px 10px 40px;
      padding: 5px;
      font-size: 14px;
  }
  #popUpNo {
      display: none;
      position: absolute;
      bottom: 0px;
      width: 60px;
      margin: 10px 0px 10px 110px;
      padding: 5px;
      font-size: 14px;
  }
  </code></pre>