title: Call a controller method from javascript in visualforce
body: <p>How can I call a controller method from VisualForce page without any onclick event happening?
  My VisualForce page would be like</p>
  
  <pre><code>&lt;apex:page standardController="Account"&gt; 
  
      &lt;script&gt;
       /* Here i need to call a controller class with out any onclick event. It should load by itselef */
  
      &lt;/script&gt;
  
  &lt;/apex:page&gt;
  </code></pre>
  
  <p>and my controller class will be like</p>
  
  <pre><code>public class OrderPadController {
      /* this will be the constructor */
  
      public PageReference openPage() {
           PageReference newpage = new Pagereference('/apex'+'/pagetoopen'+'?aid='+a.id); 
           openorderpadembed.setRedirect(false); 
           return openorderpadembed;      
      }
  </code></pre>
  
  <p>From my VisualForce page I need to call the method <code>openPage()</code>.</p>
  
  <p>Please help me out </p>