title: adding an event listener to safari
body: <p>I'm trying to add an event listener, via JavaScript for the Safari browser because it doesn't recognize the unload event of a window, apparently.  So far I have:</p>
  
  <pre><code>function init()
  {
  //add unload event handler for safari
  if (navigator.userAgent.toLowerCase().indexOf("safari")!=-1) {
      bodyElt = document.getElementsByTagName("body")[0];
       if (bodyElt) {
        bodyElt.addEventListener("unload", onUnloadHandler, false);
      }
  }
  ...
  </code></pre>