title: How to call function on page load in JS?
body: <p>I have a js function which looks like this </p>
  
  <pre><code> function showProducts(){
      document.getElementById("shopList").innerHTML = "&lt;ul&gt;&lt;li&gt;Test Text&lt;/li&gt;&lt;/ul&gt;";
   }
  </code></pre>
  
  <p>It's a function that has to show an array of my products. I've made an div with <code>id="shopList"</code> in my html page</p>
  
  <pre><code>        &lt;div id="shopList"&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>But how can I call the function to show me the text in the div? It works when I use this as my body tag but I'm not allowed to write any js code in my html or to use onload or onclick. I'm trying to do it with listeners for almost 4 hours and I still did not find a solution. Could someone help me? </p>
  
  <pre><code>     &lt;body onload="showProducts()"&gt;
  </code></pre>