Skip to content

Instantly share code, notes, and snippets.

@souri
Created May 13, 2013 11:42
Show Gist options
  • Save souri/5567743 to your computer and use it in GitHub Desktop.
Save souri/5567743 to your computer and use it in GitHub Desktop.
var phantom=require('node-phantom');
phantom.create(function(err,ph) {
ph.createPage(function(err,page) {
page.setFn('onInitialized', function() {
console.log("In initialized");
page.evaluate(function(domContentLoadedMsg) {
document.addEventListener('DOMContentLoaded', function() {
window.callPhantom('DOMContentLoaded');
}, false);
});
});
page.setFn('onLoadStarted', function() {
console.log("We are now inside onLoadStarted");
});
page.setFn('onLoadFinished', function() {
console.log("We are now inside onLoadFinished");
});
page.setFn("onDOMContentLoaded", function() {
console.log("We are now inside DOMContentLoaded. Awesome!");
ph.exit(0);
});
page.onCallback = function(data) {
console.log("DOMContentLoaded!");
//ph.exit(0);
};
page.open("http://tilomitra.com/repository/screenscrape/ajax.html");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment