<html>
<body>
<script>
function test(){
var win = window.open('','printwindow');
win.document.write('<html><head><title>Print it!</title><link href="styles.css" rel="stylesheet"
type="text/css"></link></head><body>');
console.log($("#content").html());
win.document.write($("#content").html());
win.document.write('</body></html>');
win.print();
win.close();
}
</script>
<button onclick="test()">Open window</button>
<textarea id="content"><h1>hello</h1></textarea>
</body>
</html>
Reference:
http://stackoverflow.com/questions/21224676/window-open-style-using-css
Comments
Post a Comment