I tried to use phantomjs for screen capturing my page with node-phantom bridge. Here is what I'm trying:
var phantom = require('node-phantom');
phantom.create(function (err, ph) {
return ph.createPage(function (err, page) {
return page.set('content', '<html><head></head><body><p>Hello</p></body></html>', function (err, status) {
return page.render('./content.png', function (err) {
ph.exit();
});
});
});
});
That works fine, but if I try to set content which contains javascript, that doesn't work. Please help me, why does it not work?
EDIT: This doesn't work:
var phantom = require('node-phantom');
phantom.create(function (err, ph) {
return ph.createPage(function (err, page) {
page.open("about:blank", function(err,status) {
page.evaluate(function() {
document.write('<html><head></head><body><script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script>$(function(){document.write("Hello from jQuery")})</script></body>');
});
setTimeout(function () {
return page.render('./content.png', function (err) {
ph.exit();
});
}, 5000);
});
});