Skip to content

Instantly share code, notes, and snippets.

@automata
Created September 5, 2016 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save automata/a5b65a4c882956afbada8f41143eb2cc to your computer and use it in GitHub Desktop.
Save automata/a5b65a4c882956afbada8f41143eb2cc to your computer and use it in GitHub Desktop.
Screenshot HTML content
#!/bin/bash
# First install phantomjs: `npm install phantomjs`
./node_modules/.bin/phantomjs script.js
var page = require('webpage').create();
html = '<html><head><style>button { height: 301px }</style></head><body><button>A simple button</button></body></html>';
viewport = { width: 0, height: 0 };
page.viewportSize = viewport;
page.content = html;
console.log(page.evaluate(function(){
return JSON.stringify({
"document.body.scrollHeight": document.body.scrollHeight,
"document.body.offsetHeight": document.body.offsetHeight,
"document.documentElement.clientHeight": document.documentElement.clientHeight,
"document.documentElement.scrollHeight": document.documentElement.scrollHeight
}, undefined, 4);
}));
phantom.exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment