-
-
Save martinheidegger/5567812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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