title: Angularjs Onbeforeunload without prompt not working properly
body: <p>I want to execute some code before the window closes but i don't want to display the prompt.
  Here is my code : </p>
  
  <pre><code>  $window.onbeforeunload = function(){
          $rootScope.$broadcast('war-change');
          return undefined;
      };
  
      $scope.$on('war-change',function(){
          console.log('here');
           //Execute some more code here.
          });
  </code></pre>
  
  <p>returning undefined or false is not working as my code is not getting executed.
  any help is appreciated.</p>