title: Is it possible to execute code after page load from a trigger on another page? JS
body: <p>I have a classic navbar menu with links and sublinks. One menu link is called &quot;houses&quot; and it has subitems called &quot;home1&quot;, &quot;home2&quot;, &quot;home3&quot;. On the page &quot;houses&quot; there is an html container with tabs and each tab opens a section that contains info on &quot;home1&quot;, &quot;home2&quot; and &quot;home3&quot;. Everything works well.</p>
  <p>My question is, is it possible to do the following: when i click on any sublink &quot;home1/2/3&quot; from ANOTHER page other than the &quot;houses&quot; page, the &quot;houses&quot; page should open AND the sublink that i clicked opens the respective tab?</p>
  <p>I tried a solution with Vanilla JS but as expected it only works when i am on the &quot;houses&quot; page. I understand WHY it is happening but i have no idea how to achieve this (besides asynchronous execution of some sort?).</p>
  <p>My code:</p>
  <pre><code>const menuitem = document.querySelectorAll('#menu-item-27 ul li [data-text]'); //data-text is the sublink - (&quot;home1&quot;, &quot;home2&quot;, &quot;home3&quot;)
      for(let item of menuitem) {
          item.onclick = function() {
              window.onload = function WindowLoad(event) {
                  document.querySelector('[data-tab=&quot;2&quot;]').click(); 
                  /* data-tab=1, data-tab=2, data-tab=3 is the tab element that opens the info on one of the &quot;home1/2/3&quot; divs 
                  I'm using just data-tab=2 to test the click, don't worry about that part
                  */
              }
          }
      }
  </code></pre>