title: Listen for form submission
body: <p>I need to register when a form is submitted on my site, no matter where and when - it may be dynamically loaded or created form - I need to be able to tell whenever <strong>any</strong> form is about to be submitted on the page. Event listeners are simply not an option here for the reasons mentioned above.</p>
  
  <p>I was thinking what other options I have and one of them was like if I would want to capture clicks on buttons for example, I could add a click listener to the document and check <code>event.target</code> to determine whether a button has been clicked without adding listeners to every particular button. I was hoping I could do the same with form submissions but I didn't find a suitable event to listen for on a document.</p>
  
  <p>Another solution that came to mind was to extend <code>HTMLFormElement</code> prototype and add a default <code>onclick</code> function such as</p>
  
  <pre><code>HTMLFormElement.prototype.onsubmit = function (e) {
      console.log(e);
  }
  </code></pre>
  
  <p>Unfortunately that turned out to be impossible as well, getting various errors in different browsers like</p>
  
  <ul>
  <li>TypeError: 'set onsubmit' called on an object that does not implement interface HTMLElement.</li>
  <li>Uncaught TypeError: Illegal invocation</li>
  </ul>
  
  <p>I'm running out of ideas, is this impossible?</p>
  
  <p><strong>EDIT</strong>: The question is clearly not a duplicate as I have described in my first idea exactly what is stated in the accepted answer of the suggested question and I do not see how to apply this in my case.</p>