title: Multiple window onload functions with only Javascript
body: <p>I have an external JS file that adds a window.onload function to the page.</p>
  
  <p>The basic premise is that it loads up a popup window on your website whenever the user clicks on certain link class. It's written in PHP / JS so assume that the function works by itself.</p>
  
  <p>Inside this JS file has the following code.</p>
  
  <pre><code>window.onload = function() {
    var anchors = document.getElementsByClassName("vyper-triggers");
    for (var i = 0; i &lt; anchors.length; i++) {
      var anchor = anchors[i];
      anchor.onclick = function() {
        if (isMobile.any()) {
          window.open("$url");
        } else {
          document.getElementById("clickonthis").click();
        }
      }
    }
  }
  </code></pre>
  
  <p>Now my problem is when my user wants to add 2 different popup windows, the window.onload function doesn't stack. Also because this is an embedded javascript that my user adds himself, there is no way for me to put both functions inside one big window.onload function. </p>
  
  <p>My user might put one JS file in one area of their site, and another JS file in another area, if that makes sense.</p>
  
  <p>So how do I make it so that the window.onload function will stack no matter the placing of these external JS files on the page and considering that each function must be kept separate?</p>