title: PhantomJS Login and Page Redirect
body: <p>I am trying to crawl a website which kind of have a login page seperated and jumping homepage after login. Here is my code, but I am not accomplishment jumping homepage:</p>
  
  <pre><code>var page = require('webpage').create() ;
  var login = 'https://webstie.com/login' ;
  var home = 'https://website.com/home' ;
  
  page.open(login, function (status) {
      if (status !== 'success') {
          console.log('fail!');
      } else {
          page.evaluate(function(){
              function timer (f,n) {
                  var i = 0 ;
                  var t = setInterval(function(){
                      if (n &lt; i) {
                          clearInterval(t) ;
                          f() ;
                      }
                      i++ ;
                  },50) ;
              }
              $("input[name=email]").val("user") ;
              $("input[name=password]").val("pass") ;
              $("input[type=submit]").click() ;
              timer(function(){
                  document.location.href = home ;
                  timer(function(){
                      $('body').css('border','1px solid red') ;
                  },100) ;
              },100) ;
          }) ;
          page.render('page.png') ;
      }
      console.log('finished!') ;
      phantom.exit() ;
  });
  </code></pre>