-
-
Save idibidiart/6239401 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const PHANTOM_FUNCTION_PREFIX = '/* PHANTOM_FUNCTION */'; | |
var page = require('webpage').create(); | |
page.onConsoleMessage = function(msg) { | |
if (msg.indexOf(PHANTOM_FUNCTION_PREFIX) === 0) { | |
eval('(' + msg + ')()'); | |
} else { | |
console.log(msg); | |
} | |
}; | |
page.onInitialized = function() { | |
page.evaluate(function(domContentLoadedMsg) { | |
document.addEventListener('DOMContentLoaded', function() { | |
console.log(domContentLoadedMsg); | |
}, false); | |
}, PHANTOM_FUNCTION_PREFIX + page.onDOMContentLoaded); | |
}; | |
page.onDOMContentLoaded = function() { | |
// your code here | |
console.log('DOMContentLoaded'); | |
phantom.exit(); | |
}; | |
page.open('http://phantomjs.org/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment