I tried few of the above solutions but they didn't worked for me. Here is a link to the page which worked for me automatically click a link
Above link has many solutions and here's the one which worked for me,
    <button onclick="fun();">Magic button</button>
    <!--The link you want to automatically click-->
    <a href='http://www.ercafe.com' id="myAnchor">My website</a>
Now within the <script> tags,
<script>
     function fun(){
          actuateLink(document.getElementById('myAnchor'));
     }
     function actuateLink(link)
     {
          var allowDefaultAction = true;
          if (link.click)
          {
              link.click();
              return;
          }
          else if (document.createEvent)
          {
              var e = document.createEvent('MouseEvents');
              e.initEvent(
                   'click'     // event type
                   ,true      // can bubble?
                   ,true      // cancelable?
              );
              allowDefaultAction = link.dispatchEvent(e);           
          }
          if (allowDefaultAction)       
          {
              var f = document.createElement('form');
              f.action = link.href;
              document.body.appendChild(f);
              f.submit();
          }
    }
</script>
Copy paste the above code and click on clicking the 'Magic button' button, you will be redirected to ErCafe.com.