title: PhantomJS open one page after another
body: <p>I used this example to create a phantomjs code to login to website.</p>
  
  <pre><code>var page = require('webpage').create();
  page.open("http://www.facebook.com/login.php", function(status) {
  
    if (status === "success") {
      page.onConsoleMessage = function(msg, lineNum, sourceId) {
        console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
      };
      page.evaluate(function() {
        console.log('hello');
        document.getElementById("email").value = "email";
        document.getElementById("pass").value = "password";
        document.getElementById("u_0_1").click();
        // page is redirecting.
      });
      setTimeout(function() {
        page.evaluate(function() {
          console.log('haha');
        });
        page.render("page.png");
        phantom.exit();
      }, 5000);
    }
  });
  </code></pre>
  
  <p>From this link.
  <a href="https://gist.github.com/ecin/2473860" rel="noreferrer">https://gist.github.com/ecin/2473860</a></p>
  
  <p>But I want to open another link from a button or go directly on it. How can I do it?</p>
  
  <p>Here is a simpler example. Doesn't work...</p>
  
  <pre><code>var page = require('webpage').create();
  var url = "www.example.com";
  
  page.open(url, function (status) {
  
      setTimeout(function () {
          page.evaluate(function () {
              console.log('haha');
          });
          page.render("example.png");
          phantom.exit();
      }, 5000);
  
  });
  
  
  
  var url = "www.google.com";
  
  page.open(url, function (status) {
  
      setTimeout(function () {
          page.evaluate(function () {
              console.log('haha');
          });
          page.render("google.png");
          phantom.exit();
      }, 5000);
  
  });
  </code></pre>