title: How to execute JavaScript after page load?
body: <p>I would like to execute a JavaScript function after the page was loaded. At the moment I have a commandButton and everything works fine. However it would be more comfortable if the user is not supposed to hit the button.</p>
  
  <p>I have tried f:event, but I do not have a listener, I have only the JavaScript function. Moreover body onload does not work for me as I use only high level components.</p>
  
  <pre><code>&lt;f:view xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:pm="http://primefaces.org/mobile" contentType="text/html"&gt;
  
  &lt;ui:composition template="/resources/master.xhtml"&gt;
  
      &lt;ui:define name="content"&gt;
  
  
          &lt;pm:content&gt;
  
              &lt;h:inputHidden id="address" value="#{pathFinderBean.address}" /&gt;
  
              &lt;div id="map" style="width: 100%; height: 285px;"&gt;&lt;/div&gt;
  
               &lt;p:commandButton type="button" value="Route" onclick="PathFinder.findAndGo()"/&gt;
  
              &lt;div id="route"&gt;&lt;/div&gt;
  
          &lt;/pm:content&gt;
      &lt;/ui:define&gt;
  
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p></p>
  
  <p>The JavaScript function PathFinder.findAndGo is defined in my master.xhtml</p>