Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save martinheidegger/5567812 to your computer and use it in GitHub Desktop.
Save martinheidegger/5567812 to your computer and use it in GitHub Desktop.
var phantom=require('phantom');
phantom.create(function(ph) {
ph.createPage(function(page) {
page.set('onInitialized', function() {
console.log("We are now inside onInitialized");
});
page.set('onLoadStarted', function() {
console.log("We are now inside onLoadStarted");
});
page.set('onConsoleMessage', function(arguments) {
console.log("Console message:", arguments);
});
page.set('onLoadFinished', function() {
console.log("Load finished");
});
page.set("onDOMContentLoaded", function() {
console.log("We are now inside DOMContentLoaded");
});
page.set("onCallback", function(ev) {
console.info(ev);
});
page.open("http://tilomitra.com/repository/screenscrape/ajax.html", function(status) {
console.log(status);
page.evaluate(function() {
document.addEventListener("DOMContentLoaded", function() {
console.log("DOMContentLoaded");
window.callPhantom("DOMContentLoaded");
}, false);
setTimeout(function() {
console.info("Console works!");
window.callPhantom("calling Phantom works too");
}, 80);
return "hello";
}, function(result) {console.log(result);});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment