title: document.ActiveElement not returning the active element in Safari
body: <p>In the web site I am writing there is the need for some confirmation text to be shown before something happens. The solution I am using shows a modal window on the button click and when the window is closed the Jquery looks at which button was clicked.</p>
  
  <p>So I have the following for a logout confirmation</p>
  
  <pre><code>$(function () {
      $('#logOut').on('click', function () {
          url = $(this).data('request-url');
          $('#modalLogout').modal('show');
      });
  
      $('#modalLogout').on('hide.bs.modal', function () {
          var activeElement = $(document.activeElement);
  
          if (activeElement.is('[data-toggle], [data-dismiss]')) {
              if (activeElement[0].id === "LogoutOk") {
                  window.location.href = url;
              }
          }
      });
  });
  </code></pre>
  
  <p>and the modal window</p>
  
  <pre><code>&lt;div id="modalLogout" class="modal fade" role="dialog"&gt;
  &lt;div class="modal-dialog modal-sm" role="document"&gt;
      &lt;div class="modal-content"&gt;
          &lt;div class="modal-body"&gt;
              &lt;p&gt;Do you want to log out?&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="btn btn-default" data-dismiss="modal" id="LogoutCancel"&gt;Cancel&lt;/button&gt;
              &lt;button type="button" class="btn btn-warning" data-dismiss="modal" id="LogoutOk"&gt;OK&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In windows I have tested the above in IE, Edge, Firefox and Chrome and it all works as I would expect it to - when the modal window closes the user is logged out only if the OK button was pressed, clicking anywhere else will leave you logged in.</p>
  
  <p>On a Mac using Safari, clicking OK will do nothing. Looking at the console, the problem appears to be the <code>$(document.activeElement)</code>. In a windows browser this will return the button that was clicked, in Safari I get the the whole web page starting with the <code>&lt;body&gt;</code>.</p>
  
  <p>Reading around the net there seems to be a (small) amount of discussion on the subject of activeElement in Safari, but not as much as I would expect if a lot of people are doing something similar. None of the solutions I have looked at are applicable in my case.</p>
  
  <p>Is there a way to get the clicked button in Safari, or is there a better way to achieve what I am after that will work in all browsers?</p>