Created
February 10, 2013 10:55
-
-
Save zhchbin/4749217 to your computer and use it in GitHub Desktop.
Node-Webkit API Demo: Window.capturePage
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
<html> | |
<body style="background: #333"> | |
<script > | |
var gui = require('nw.gui'); | |
var win = gui.Window.get(); | |
function takeSnapshot() { | |
win.capturePage(function(img) { | |
var popWindow = gui.Window.open('popup.html', | |
{width: 420, height: 300}); | |
popWindow.on('loaded', function() { | |
var image = popWindow.window.document.getElementById('image'); | |
image.src = img; | |
}); | |
}, 'png'); | |
} | |
</script> | |
<div style="background: #123; width:100px; height:100px; border:1px solid | |
#000"> | |
</div> | |
<button onclick="takeSnapshot()">Click me</button> | |
</body> | |
</html> |
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
{ | |
"name": "nw-api-demo", | |
"main": "index.html" | |
} |
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
<html> | |
<head> | |
<title>Popup window</title> | |
<style> | |
img{ | |
width: 400; | |
} | |
</style> | |
</head> | |
<body> | |
<img id="image"/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could you feed in a string of .html from memory to capturePage?