Skip to content

Instantly share code, notes, and snippets.

@ahomu ahomu/snapshot.js
Created Nov 6, 2012

Embed
What would you like to do?
% phantomjs snapshot.js > stdoutfilename
var page = require('webpage').create();
var url = 'http://localhost:1234/';
page.viewportSize = {
width: 1024,
height: 768
};
page.settings.userAgent = 'I am Phantom';
page.open(url, function (a, b, c) {
setTimeout(function() {
console.log(page.content);
phantom.exit();
}, 2000);
/*
// browser JavaScript call `window.callPhantom` when receive request from PhantomJS
if (navigator.userAgent.toUpperCase().indexOf('PHANTOM') !== -1) {
window.callPhantom();
}
// phantomjs's onCallback
page.onCallback = function() {
console.log(page.content);
phantom.exit();
};
*/
});
@ahomu

This comment has been minimized.

Copy link
Owner Author

commented Nov 6, 2012

if ('callPhantom' in window) {
  window.callPhantom()
}

also correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.